Skip to content

Commit

Permalink
Use port numbers instead of names in prometheus annotations. (#288)
Browse files Browse the repository at this point in the history
Prometheus scrape configs often use the `prometheus.io/port` annotation
to configure targets per pod:

```
- source_labels: [__address__, __meta_kubernetes_pod_annotation_prometheus_io_port]
  action: replace
  regex: ([^:]+)(?::\d+)?;(\d+)
  replacement: $1:$2
  target_label: __address__
```

This rule only matches when the `prometheus.io/port` annotation is a
port number, and it's not clear to me how the scrape config could be
modified to work with port names. To make the chart compatible with
standard prometheus scrape configs, this patch changes the default port
annotation from port names to port numbers.

Signed-off-by: Josh Carp <[email protected]>
  • Loading branch information
jmcarp authored Dec 13, 2021
1 parent 62183e2 commit 118f8ad
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 24 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## master / unreleased
* [CHANGE] Use port number for prometheus port annotations. #288
* [CHANGE] Disable ingester startup probes by default. #286
* [FEATURE] Optionally manage cortex config as configmap. #280
* [ENHANCEMENT] Upgrade to Cortex v1.11.0 #272
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ Kubernetes: `^1.19.0-0`
| alertmanager.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;size | string | `"2Gi"` | Alertmanager data Persistent Volume size |
| alertmanager.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;storageClass | string | `nil` | Alertmanager data Persistent Volume Storage Class If defined, storageClassName: <storageClass> If set to "-", storageClassName: "", which disables dynamic provisioning If undefined (the default) or set to null, no storageClassName spec is set, choosing the default provisioner. |
| alertmanager.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;subPath | string | `""` | Subdirectory of Alertmanager data Persistent Volume to mount Useful if the volume's root directory is not empty |
| alertmanager.&ZeroWidthSpace;podAnnotations | object | `{"prometheus.io/port":"http-metrics","prometheus.io/scrape":"true"}` | Pod Annotations |
| alertmanager.&ZeroWidthSpace;podAnnotations | object | `{"prometheus.io/port":"8080","prometheus.io/scrape":"true"}` | Pod Annotations |
| alertmanager.&ZeroWidthSpace;podDisruptionBudget | object | `{"maxUnavailable":1}` | If not set then a PodDisruptionBudget will not be created |
| alertmanager.&ZeroWidthSpace;podLabels | object | `{}` | Pod Labels |
| alertmanager.&ZeroWidthSpace;readinessProbe.&ZeroWidthSpace;httpGet.&ZeroWidthSpace;path | string | `"/ready"` | |
Expand Down Expand Up @@ -174,7 +174,7 @@ Kubernetes: `^1.19.0-0`
| compactor.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;size | string | `"2Gi"` | |
| compactor.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;storageClass | string | `nil` | compactor data Persistent Volume Storage Class If defined, storageClassName: <storageClass> If set to "-", storageClassName: "", which disables dynamic provisioning If undefined (the default) or set to null, no storageClassName spec is set, choosing the default provisioner. |
| compactor.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;subPath | string | `""` | Subdirectory of compactor data Persistent Volume to mount Useful if the volume's root directory is not empty |
| compactor.&ZeroWidthSpace;podAnnotations | object | `{"prometheus.io/port":"http-metrics","prometheus.io/scrape":"true"}` | Pod Annotations |
| compactor.&ZeroWidthSpace;podAnnotations | object | `{"prometheus.io/port":"8080","prometheus.io/scrape":"true"}` | Pod Annotations |
| compactor.&ZeroWidthSpace;podDisruptionBudget.&ZeroWidthSpace;maxUnavailable | int | `1` | |
| compactor.&ZeroWidthSpace;podLabels | object | `{}` | Pod Labels |
| compactor.&ZeroWidthSpace;readinessProbe.&ZeroWidthSpace;httpGet.&ZeroWidthSpace;path | string | `"/ready"` | |
Expand Down Expand Up @@ -263,7 +263,7 @@ Kubernetes: `^1.19.0-0`
| configs.&ZeroWidthSpace;livenessProbe.&ZeroWidthSpace;httpGet.&ZeroWidthSpace;port | string | `"http-metrics"` | |
| configs.&ZeroWidthSpace;nodeSelector | object | `{}` | |
| configs.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;subPath | string | `nil` | |
| configs.&ZeroWidthSpace;podAnnotations | object | `{"prometheus.io/port":"http-metrics","prometheus.io/scrape":"true"}` | Pod Annotations |
| configs.&ZeroWidthSpace;podAnnotations | object | `{"prometheus.io/port":"8080","prometheus.io/scrape":"true"}` | Pod Annotations |
| configs.&ZeroWidthSpace;podDisruptionBudget.&ZeroWidthSpace;maxUnavailable | int | `1` | |
| configs.&ZeroWidthSpace;podLabels | object | `{}` | Pod Labels |
| configs.&ZeroWidthSpace;readinessProbe.&ZeroWidthSpace;httpGet.&ZeroWidthSpace;path | string | `"/ready"` | |
Expand Down Expand Up @@ -318,7 +318,7 @@ Kubernetes: `^1.19.0-0`
| distributor.&ZeroWidthSpace;livenessProbe.&ZeroWidthSpace;httpGet.&ZeroWidthSpace;port | string | `"http-metrics"` | |
| distributor.&ZeroWidthSpace;nodeSelector | object | `{}` | |
| distributor.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;subPath | string | `nil` | |
| distributor.&ZeroWidthSpace;podAnnotations | object | `{"prometheus.io/port":"http-metrics","prometheus.io/scrape":"true"}` | Pod Annotations |
| distributor.&ZeroWidthSpace;podAnnotations | object | `{"prometheus.io/port":"8080","prometheus.io/scrape":"true"}` | Pod Annotations |
| distributor.&ZeroWidthSpace;podDisruptionBudget.&ZeroWidthSpace;maxUnavailable | int | `1` | |
| distributor.&ZeroWidthSpace;podLabels | object | `{}` | Pod Labels |
| distributor.&ZeroWidthSpace;readinessProbe.&ZeroWidthSpace;httpGet.&ZeroWidthSpace;path | string | `"/ready"` | |
Expand Down Expand Up @@ -379,7 +379,7 @@ Kubernetes: `^1.19.0-0`
| ingester.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;size | string | `"2Gi"` | Ingester data Persistent Volume size |
| ingester.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;storageClass | string | `nil` | Ingester data Persistent Volume Storage Class If defined, storageClassName: <storageClass> If set to "-", storageClassName: "", which disables dynamic provisioning If undefined (the default) or set to null, no storageClassName spec is set, choosing the default provisioner. |
| ingester.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;subPath | string | `""` | Subdirectory of Ingester data Persistent Volume to mount Useful if the volume's root directory is not empty |
| ingester.&ZeroWidthSpace;podAnnotations | object | `{"prometheus.io/port":"http-metrics","prometheus.io/scrape":"true"}` | Pod Annotations |
| ingester.&ZeroWidthSpace;podAnnotations | object | `{"prometheus.io/port":"8080","prometheus.io/scrape":"true"}` | Pod Annotations |
| ingester.&ZeroWidthSpace;podDisruptionBudget.&ZeroWidthSpace;maxUnavailable | int | `1` | |
| ingester.&ZeroWidthSpace;podLabels | object | `{}` | Pod Labels |
| ingester.&ZeroWidthSpace;readinessProbe.&ZeroWidthSpace;httpGet.&ZeroWidthSpace;path | string | `"/ready"` | |
Expand Down Expand Up @@ -490,7 +490,7 @@ Kubernetes: `^1.19.0-0`
| nginx.&ZeroWidthSpace;livenessProbe.&ZeroWidthSpace;httpGet.&ZeroWidthSpace;port | string | `"http-metrics"` | |
| nginx.&ZeroWidthSpace;nodeSelector | object | `{}` | |
| nginx.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;subPath | string | `nil` | |
| nginx.&ZeroWidthSpace;podAnnotations | object | `{"prometheus.io/port":"http-metrics","prometheus.io/scrape":""}` | Pod Annotations |
| nginx.&ZeroWidthSpace;podAnnotations | object | `{}` | Pod Annotations |
| nginx.&ZeroWidthSpace;podDisruptionBudget.&ZeroWidthSpace;maxUnavailable | int | `1` | |
| nginx.&ZeroWidthSpace;podLabels | object | `{}` | Pod Labels |
| nginx.&ZeroWidthSpace;readinessProbe.&ZeroWidthSpace;httpGet.&ZeroWidthSpace;path | string | `"/healthz"` | |
Expand Down Expand Up @@ -536,7 +536,7 @@ Kubernetes: `^1.19.0-0`
| querier.&ZeroWidthSpace;livenessProbe.&ZeroWidthSpace;httpGet.&ZeroWidthSpace;port | string | `"http-metrics"` | |
| querier.&ZeroWidthSpace;nodeSelector | object | `{}` | |
| querier.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;subPath | string | `nil` | |
| querier.&ZeroWidthSpace;podAnnotations | object | `{"prometheus.io/port":"http-metrics","prometheus.io/scrape":"true"}` | Pod Annotations |
| querier.&ZeroWidthSpace;podAnnotations | object | `{"prometheus.io/port":"8080","prometheus.io/scrape":"true"}` | Pod Annotations |
| querier.&ZeroWidthSpace;podDisruptionBudget.&ZeroWidthSpace;maxUnavailable | int | `1` | |
| querier.&ZeroWidthSpace;podLabels | object | `{}` | Pod Labels |
| querier.&ZeroWidthSpace;readinessProbe.&ZeroWidthSpace;httpGet.&ZeroWidthSpace;path | string | `"/ready"` | |
Expand Down Expand Up @@ -580,7 +580,7 @@ Kubernetes: `^1.19.0-0`
| query_frontend.&ZeroWidthSpace;livenessProbe.&ZeroWidthSpace;httpGet.&ZeroWidthSpace;port | string | `"http-metrics"` | |
| query_frontend.&ZeroWidthSpace;nodeSelector | object | `{}` | |
| query_frontend.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;subPath | string | `nil` | |
| query_frontend.&ZeroWidthSpace;podAnnotations | object | `{"prometheus.io/port":"http-metrics","prometheus.io/scrape":"true"}` | Pod Annotations |
| query_frontend.&ZeroWidthSpace;podAnnotations | object | `{"prometheus.io/port":"8080","prometheus.io/scrape":"true"}` | Pod Annotations |
| query_frontend.&ZeroWidthSpace;podDisruptionBudget.&ZeroWidthSpace;maxUnavailable | int | `1` | |
| query_frontend.&ZeroWidthSpace;podLabels | object | `{}` | Pod Labels |
| query_frontend.&ZeroWidthSpace;readinessProbe.&ZeroWidthSpace;httpGet.&ZeroWidthSpace;path | string | `"/ready"` | |
Expand Down Expand Up @@ -621,7 +621,7 @@ Kubernetes: `^1.19.0-0`
| ruler.&ZeroWidthSpace;livenessProbe.&ZeroWidthSpace;httpGet.&ZeroWidthSpace;port | string | `"http-metrics"` | |
| ruler.&ZeroWidthSpace;nodeSelector | object | `{}` | |
| ruler.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;subPath | string | `nil` | |
| ruler.&ZeroWidthSpace;podAnnotations | object | `{"prometheus.io/port":"http-metrics","prometheus.io/scrape":"true"}` | Pod Annotations |
| ruler.&ZeroWidthSpace;podAnnotations | object | `{"prometheus.io/port":"8080","prometheus.io/scrape":"true"}` | Pod Annotations |
| ruler.&ZeroWidthSpace;podDisruptionBudget.&ZeroWidthSpace;maxUnavailable | int | `1` | |
| ruler.&ZeroWidthSpace;podLabels | object | `{}` | Pod Labels |
| ruler.&ZeroWidthSpace;readinessProbe.&ZeroWidthSpace;httpGet.&ZeroWidthSpace;path | string | `"/ready"` | |
Expand Down Expand Up @@ -684,7 +684,7 @@ Kubernetes: `^1.19.0-0`
| store_gateway.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;size | string | `"2Gi"` | Store-gateway data Persistent Volume size |
| store_gateway.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;storageClass | string | `nil` | Store-gateway data Persistent Volume Storage Class If defined, storageClassName: <storageClass> If set to "-", storageClassName: "", which disables dynamic provisioning If undefined (the default) or set to null, no storageClassName spec is set, choosing the default provisioner. |
| store_gateway.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;subPath | string | `""` | Subdirectory of Store-gateway data Persistent Volume to mount Useful if the volume's root directory is not empty |
| store_gateway.&ZeroWidthSpace;podAnnotations | object | `{"prometheus.io/port":"http-metrics","prometheus.io/scrape":"true"}` | Pod Annotations |
| store_gateway.&ZeroWidthSpace;podAnnotations | object | `{"prometheus.io/port":"8080","prometheus.io/scrape":"true"}` | Pod Annotations |
| store_gateway.&ZeroWidthSpace;podDisruptionBudget.&ZeroWidthSpace;maxUnavailable | int | `1` | |
| store_gateway.&ZeroWidthSpace;podLabels | object | `{}` | Pod Labels |
| store_gateway.&ZeroWidthSpace;readinessProbe.&ZeroWidthSpace;httpGet.&ZeroWidthSpace;path | string | `"/ready"` | |
Expand Down Expand Up @@ -724,7 +724,7 @@ Kubernetes: `^1.19.0-0`
| table_manager.&ZeroWidthSpace;livenessProbe.&ZeroWidthSpace;httpGet.&ZeroWidthSpace;port | string | `"http-metrics"` | |
| table_manager.&ZeroWidthSpace;nodeSelector | object | `{}` | |
| table_manager.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;subPath | string | `nil` | |
| table_manager.&ZeroWidthSpace;podAnnotations | object | `{"prometheus.io/port":"http-metrics","prometheus.io/scrape":"true"}` | Pod Annotations |
| table_manager.&ZeroWidthSpace;podAnnotations | object | `{"prometheus.io/port":"8080","prometheus.io/scrape":"true"}` | Pod Annotations |
| table_manager.&ZeroWidthSpace;podDisruptionBudget.&ZeroWidthSpace;maxUnavailable | int | `1` | |
| table_manager.&ZeroWidthSpace;podLabels | object | `{}` | Pod Labels |
| table_manager.&ZeroWidthSpace;readinessProbe.&ZeroWidthSpace;httpGet.&ZeroWidthSpace;path | string | `"/ready"` | |
Expand Down
24 changes: 11 additions & 13 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ alertmanager:
# -- Pod Annotations
podAnnotations:
prometheus.io/scrape: 'true'
prometheus.io/port: 'http-metrics'
prometheus.io/port: '8080'

nodeSelector: {}
affinity: {}
Expand Down Expand Up @@ -345,7 +345,7 @@ distributor:
# -- Pod Annotations
podAnnotations:
prometheus.io/scrape: 'true'
prometheus.io/port: 'http-metrics'
prometheus.io/port: '8080'

nodeSelector: {}
affinity:
Expand Down Expand Up @@ -453,7 +453,7 @@ ingester:
# -- Pod Annotations
podAnnotations:
prometheus.io/scrape: 'true'
prometheus.io/port: 'http-metrics'
prometheus.io/port: '8080'

nodeSelector: {}
affinity:
Expand Down Expand Up @@ -605,7 +605,7 @@ ruler:
# -- Pod Annotations
podAnnotations:
prometheus.io/scrape: 'true'
prometheus.io/port: 'http-metrics'
prometheus.io/port: '8080'

nodeSelector: {}
affinity: {}
Expand Down Expand Up @@ -723,7 +723,7 @@ querier:
# -- Pod Annotations
podAnnotations:
prometheus.io/scrape: 'true'
prometheus.io/port: 'http-metrics'
prometheus.io/port: '8080'

nodeSelector: {}
affinity:
Expand Down Expand Up @@ -825,7 +825,7 @@ query_frontend:
# -- Pod Annotations
podAnnotations:
prometheus.io/scrape: 'true'
prometheus.io/port: 'http-metrics'
prometheus.io/port: '8080'

nodeSelector: {}
affinity:
Expand Down Expand Up @@ -915,7 +915,7 @@ table_manager:
# -- Pod Annotations
podAnnotations:
prometheus.io/scrape: 'true'
prometheus.io/port: 'http-metrics'
prometheus.io/port: '8080'

nodeSelector: {}
affinity: {}
Expand Down Expand Up @@ -994,7 +994,7 @@ configs:
# -- Pod Annotations
podAnnotations:
prometheus.io/scrape: 'true'
prometheus.io/port: 'http-metrics'
prometheus.io/port: '8080'

nodeSelector: {}
affinity: {}
Expand Down Expand Up @@ -1105,9 +1105,7 @@ nginx:
podLabels: {}

# -- Pod Annotations
podAnnotations:
prometheus.io/scrape: ''
prometheus.io/port: 'http-metrics'
podAnnotations: {}

nodeSelector: {}
affinity: {}
Expand Down Expand Up @@ -1195,7 +1193,7 @@ store_gateway:
# -- Pod Annotations
podAnnotations:
prometheus.io/scrape: 'true'
prometheus.io/port: 'http-metrics'
prometheus.io/port: '8080'

nodeSelector: {}
affinity:
Expand Down Expand Up @@ -1313,7 +1311,7 @@ compactor:
# -- Pod Annotations
podAnnotations:
prometheus.io/scrape: 'true'
prometheus.io/port: 'http-metrics'
prometheus.io/port: '8080'

nodeSelector: {}
affinity:
Expand Down

0 comments on commit 118f8ad

Please sign in to comment.