Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a conditional to enable or disable bearer token in auto discovery #686

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions charts/k8s-monitoring/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,7 @@ The Prometheus and Loki services may be hosted on the same cluster, or remotely
| metrics.autoDiscover.annotations.metricsScheme | string | `"k8s.grafana.com/metrics.scheme"` | Annotation for setting the metrics scheme, default: http. |
| metrics.autoDiscover.annotations.metricsScrapeInterval | string | `"k8s.grafana.com/metrics.scrapeInterval"` | Annotation for overriding the scrape interval for this service or pod. Value should be a duration like "15s, 1m". Overrides metrics.autoDiscover.scrapeInterval |
| metrics.autoDiscover.annotations.scrape | string | `"k8s.grafana.com/scrape"` | Annotation for enabling scraping for this service or pod. Value should be either "true" or "false" |
| metrics.autoDiscover.bearerToken | object | `{"enabled":true}` | Sets bearer_token_file line in the prometheus.scrape annotation_autodiscovery. |
| metrics.autoDiscover.enabled | bool | `true` | Enable annotation-based auto-discovery |
| metrics.autoDiscover.extraMetricRelabelingRules | string | `""` | Rule blocks to be added to the prometheus.relabel component for auto-discovered entities. These relabeling rules are applied post-scrape against the metrics returned from the scraped target, no `__meta*` labels are present. ([docs](https://grafana.com/docs/alloy/latest/reference/components/prometheus.relabel/#rule-block)) |
| metrics.autoDiscover.extraRelabelingRules | string | `""` | Rule blocks to be added to the discovery.relabel component for auto-discovered entities. These relabeling rules are applied pre-scrape against the targets from service discovery. Before the scrape, any remaining target labels that start with `__` (i.e. `__meta_kubernetes*`) are dropped. ([docs](https://grafana.com/docs/alloy/latest/reference/components/discovery.relabel/#rule-block)) |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ prometheus.scrape "annotation_autodiscovery_http" {
targets = discovery.relabel.annotation_autodiscovery_http.output
scrape_interval = {{ .Values.metrics.autoDiscover.scrapeInterval | default .Values.metrics.scrapeInterval | quote }}
honor_labels = true
{{- if .Values.metrics.autoDiscover.bearerToken.enabled }}
bearer_token_file = "/var/run/secrets/kubernetes.io/serviceaccount/token"
{{- end }}
{{- if .Values.alloy.alloy.clustering.enabled }}
clustering {
enabled = true
Expand All @@ -183,7 +185,9 @@ prometheus.scrape "annotation_autodiscovery_https" {
targets = discovery.relabel.annotation_autodiscovery_https.output
scrape_interval = {{ .Values.metrics.autoDiscover.scrapeInterval | default .Values.metrics.scrapeInterval | quote }}
honor_labels = true
{{- if .Values.metrics.autoDiscover.bearerToken.enabled }}
bearer_token_file = "/var/run/secrets/kubernetes.io/serviceaccount/token"
{{- end }}
tls_config {
insecure_skip_verify = true
}
Expand Down
8 changes: 8 additions & 0 deletions charts/k8s-monitoring/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1263,6 +1263,14 @@
"null"
]
},
"bearerToken": {
"type": "object",
"properties": {
"enabled": {
"type": "boolean"
}
}
},
"metricsTuning": {
"type": "object",
"properties": {
Expand Down
5 changes: 5 additions & 0 deletions charts/k8s-monitoring/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,11 @@ metrics:
# @section -- Metrics Job: Auto-Discovery
maxCacheSize:

# -- Sets bearer_token_file line in the prometheus.scrape annotation_autodiscovery.
# @section -- Metrics Job: Auto-Discovery
bearerToken:
enabled: true

# Metrics from Grafana Alloy
# @section -- Metrics -> Alloy Job
alloy:
Expand Down
Loading