Skip to content

Commit

Permalink
feat: custom metric sources (#37)
Browse files Browse the repository at this point in the history
* feat: add custom metric sources

* feat: add secrets

* fix: remove data from reloader container

* style: yamllint

* feat: allow custom rules

* fix: do not include if empty

* fix: empty secrets for default values file

* docs: update
  • Loading branch information
agrrh authored Dec 14, 2023
1 parent 9fdaaf9 commit cc26c91
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 11 deletions.
20 changes: 11 additions & 9 deletions deploy/helm/pagetron/templates/prometheus.configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ data:
- targets:
- blackbox:9115
# resources
# resources: {{ len $.Values.targets }} item(s)
{{- if gt (len $.Values.targets) 0 }}
- job_name: "blackbox"
metrics_path: /probe
params:
Expand All @@ -60,6 +61,12 @@ data:
target_label: instance
- target_label: __address__
replacement: blackbox:9115
{{- end }}
# custom metrics sources: {{ len $.Values.customMetricSources }} item(s)
{{- if gt (len $.Values.customMetricSources) 0 }}
{{- toYaml $.Values.customMetricSources | nindent 6 }}
{{- end }}
rules_pagetron.yaml: |
groups:
Expand All @@ -68,25 +75,20 @@ data:
rules:
- record: pagetron:availability:1m
expr: |-
sum by (instance) (
probe_success == bool 1
and probe_http_status_code >= bool 200
and probe_http_status_code < bool 300
and probe_duration_seconds < bool 2
)
{{- $.Values.query1m | nindent 14 }}
- name: pagetron_hour
interval: 60s
rules:
- record: pagetron:availability:1h
expr: |-
avg_over_time(pagetron:availability:1m[60m:1m])
avg_over_time(pagetron:availability:1m[60m:1m])
- name: pagetron_day
interval: 30m
rules:
- record: pagetron:availability:1d
expr: |-
avg_over_time(pagetron:availability:1h[24h:30m])
avg_over_time(pagetron:availability:1h[24h:30m])
{{- end }}
14 changes: 12 additions & 2 deletions deploy/helm/pagetron/templates/prometheus.deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ spec:
- name: data
mountPath: /prometheus

{{- range $secret := $.Values.additionalSecrets }}
- name: secret-{{ $secret }}
readOnly: true
mountPath: "/secrets/{{ $secret }}"
{{- end }}

resources:
{{- toYaml .resources | nindent 12 }}

Expand All @@ -87,8 +93,6 @@ spec:
volumeMounts:
- name: config
mountPath: /config
- name: data
mountPath: /prometheus

resources:
limits:
Expand All @@ -108,6 +112,12 @@ spec:
persistentVolumeClaim:
claimName: pagetron-prometheus-data

{{- range $secret := $.Values.additionalSecrets }}
- name: secret-{{ $secret }}
secret:
secretName: {{ $secret }}
{{- end }}

{{- with .nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
Expand Down
72 changes: 72 additions & 0 deletions deploy/helm/pagetron/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,78 @@ publicUrl: "https://pagetron.example.org"
# May be changed to use external Prometheus
prometheusUrl: "http://prometheus:9090/"

#
# User may want to change default availability check rule
#
# Result MUST be in form of:
# - labels:
# - "instance" - REQUIRED with target name as value, e.g. "https://example.com"
# - other labels allowed
# - value: integer, 1 if considered available, otherwise 0
#
query1m: |-
sum by (instance) (
probe_success == bool 1
and probe_http_status_code >= bool 200
and probe_http_status_code < bool 300
and probe_duration_seconds < bool 2
)
# State any external metrics here
# Use scrape_config format:
# https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_config
customMetricSources: []
# AWS
# Cloudwatch Exporter
# https://github.com/prometheus/cloudwatch_exporter
#
# - job_name: aws-cloudwatch-exporter
# scheme: http
# metrics_path: /metrics
# static_configs:
# - targets:
# - cloudwatch-exporter:9106

# AWS
# Yet Another Cloudwatch Exporter
# https://github.com/nerdswords/yet-another-cloudwatch-exporter
#
# - job_name: aws-yace
# scheme: http
# metrics_path: /metrics
# static_configs:
# - targets:
# - aws-yace:5000

#
# Yandex Cloud
# https://cloud.yandex.com/en-ru/docs/monitoring/operations/metric/prometheusExport
#
# - job_name: yc-monitoring-export
# metrics_path: /monitoring/v2/prometheusMetrics
# scheme: https
# params:
# folderId:
# - my-folder
# service:
# - application-load-balancer
# bearer_token_file: /secrets/yandex-cloud/bearer.key
# static_configs:
# - targets:
# - monitoring.api.cloud.yandex.net
# labels:
# service: application-load-balancer
# folderId: my-folder

# Secret expected to be:
# - Created separately
# - Located in same namespace
# These would be mounted to `/secrets` path as separate directories
# Operator may mention those in custom metric sources list
additionalSecrets: []
# - my-exporter-token
# - yandex-cloud

backend:
replicas: 2
image:
Expand Down

0 comments on commit cc26c91

Please sign in to comment.