From c43e4344b731cd74c122150105095e164826c735 Mon Sep 17 00:00:00 2001 From: vilorij Date: Tue, 8 Sep 2020 10:40:10 +0300 Subject: [PATCH] Metrics (#28) * add prometheus operator * Autodeploy internal sservicemonitor * add readme for prom metrics * change port name to api Co-authored-by: Dmitry Skokov --- README.md | 9 +++++++++ config/prometheus/values.yaml | 12 ++++++++++++ helmfile.lock | 7 +++++-- helmfile.yaml | 5 +++++ 4 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 config/prometheus/values.yaml diff --git a/README.md b/README.md index 296be60..9b23acf 100644 --- a/README.md +++ b/README.md @@ -140,3 +140,12 @@ kubectl port-forward vault-0 8200:8200 & vault.hashicorp.com/role: "db-app" ``` После этого в поде с сервисом будет лежать файл `/vault/secrets/db-creds` со строкой подключения к БД + +Как включить сбор метрик +---------- + +requrements: + - Service c именем порта api, на котором слушает http порт приложения + - label + ``` prometheusmetrics.enabled: "true" ``` + - Метрики приложения в формате prometheus должны отдаваться на локейшене /metrics diff --git a/config/prometheus/values.yaml b/config/prometheus/values.yaml new file mode 100644 index 0000000..52ef1fe --- /dev/null +++ b/config/prometheus/values.yaml @@ -0,0 +1,12 @@ +# Look for reference at https://github.com/helm/charts/blob/master/stable/prometheus-operator/values.yaml#L1975 +prometheus: + additionalServiceMonitors: + - name: "rbk-intservice" + selector: + matchLabels: + prometheusmetrics.enabled: "true" + + endpoints: + - port: "api" + path: /metrics + scheme: http diff --git a/helmfile.lock b/helmfile.lock index 0030902..24e8b42 100644 --- a/helmfile.lock +++ b/helmfile.lock @@ -6,11 +6,14 @@ dependencies: - name: kafka repository: https://kubernetes-charts-incubator.storage.googleapis.com version: 0.21.2 +- name: prometheus-operator + repository: https://kubernetes-charts.storage.googleapis.com + version: 9.3.1 - name: vault repository: https://helm.releases.hashicorp.com version: 0.7.0 - name: zookeeper repository: https://kubernetes-charts-incubator.storage.googleapis.com version: 2.1.3 -digest: sha256:65f2c87582a6fee57134df871d6fc07d860248fa99a6c86473195e283089cb00 -generated: "2020-08-26T14:22:40.087884+03:00" +digest: sha256:adf3d2d7db5150fa436914ba61d2183ae84b260b6195cdf97af68748bcff9923 +generated: "2020-09-04T11:17:29.545997+03:00" diff --git a/helmfile.yaml b/helmfile.yaml index 4e3d3a1..d5f0aef 100644 --- a/helmfile.yaml +++ b/helmfile.yaml @@ -185,3 +185,8 @@ releases: file: config/api-common/keys/token-encryption-keys/1.jwk - name: wapiPrivkey file: config/api-common/keys/capi.privkey.pem +- name: prometheus + <<: *default + chart: stable/prometheus-operator + namespace: monitoring + createNamespace: true