Skip to content

Commit

Permalink
support auto reload for config and scrape config (#61)
Browse files Browse the repository at this point in the history
* support auto reload for config and scrape config

* f
  • Loading branch information
LeoQuote authored Feb 18, 2024
1 parent bc1c1ef commit 61f5247
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 5 deletions.
4 changes: 2 additions & 2 deletions charts/tencentcloud-exporter/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0
version: 0.2.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "v2.8.0"
home: https://github.com/tencentyun/tencentcloud-exporter
home: https://github.com/douban/tencentcloud-exporter
maintainers:
- name: LeoQuote
7 changes: 4 additions & 3 deletions charts/tencentcloud-exporter/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ spec:
{{- include "tencentcloud-exporter.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
checksum/config: {{ .Values.extraConfigs | toString| sha256sum }}
{{- if .Values.podAnnotations -}}
{{ toYaml .Values.podAnnotations | nindent 8 }}
{{- end }}
labels:
{{- include "tencentcloud-exporter.selectorLabels" . | nindent 8 }}
spec:
Expand Down
23 changes: 23 additions & 0 deletions charts/tencentcloud-exporter/templates/scrapeconfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{{- if .Values.scrapeConfig.enabled }}
apiVersion: monitoring.coreos.com/v1alpha1
kind: ScrapeConfig
metadata:
labels:
{{ include "tencentcloud-exporter.labels" . | indent 4 }}
name: {{ template "tencentcloud-exporter.fullname" . }}
spec:
staticConfigs:
- targets:
- {{ include "tencentcloud-exporter.fullname" . }}.{{ .Release.Namespace }}:{{ .Values.service.port }}
metricsPath: {{ .Values.scrapeConfig.telemetryPath }}
{{- if .Values.scrapeConfig.relabelings }}
relabelings:
{{ toYaml .Values.scrapeConfig.relabelings | indent 4 }}
{{- end }}
{{- if .Values.scrapeConfig.metricRelabelings }}
metricRelabelings:
{{ toYaml .Values.scrapeConfig.metricRelabelings | indent 4 }}
{{- end }}
scrapeInterval: {{ .Values.scrapeConfig.interval }}
scrapeTimeout: {{ .Values.scrapeConfig.timeout }}
{{- end }}
16 changes: 16 additions & 0 deletions charts/tencentcloud-exporter/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,22 @@ serviceMonitor:
# targetLabels: []
# metricRelabelings: []

scrapeConfig:
# Use https://prometheus-operator.dev/docs/user-guides/scrapeconfig/ to congfigure scrapeConfig
# It is advbised to use scrapeConfig instead of servicemonitor, as it is more flexible
# ServiceMonitor and scrapeConfig can be enabled at the same time, but it is not recommended
# When set true then use a ScrapeConfig to configure scraping
enabled: false
timeout: 10s
interval: 1m
telemetryPath: /metrics
relabelings:
- regex: 'container|endpoint|pod|service|instance'
action: "labeldrop"
metricRelabelings:
- regex: 'instance'
action: "labeldrop"

## Custom PrometheusRules to be defined
## The value is evaluated as a template, so, for example, the value can depend on .Release or .Chart
## ref: https://github.com/coreos/prometheus-operator#customresourcedefinitions
Expand Down

0 comments on commit 61f5247

Please sign in to comment.