Для включения метрик prometheus Проекты VK WorkSpace необходимо установить параметр PROM_METRICS_ENABLED: true в файле .env.
В prometheus необходимо создать ScrapeConfig по каждому сервису.
Например для kube-prometheus-stack
apiVersion: monitoring.coreos.com/v1alpha1kind: ScrapeConfigmetadata:name: workspacenamespace: monitoringlabels:prometheus: system-monitoring-prometheusspec:scrapeInterval: 30sstaticConfigs:- targets:- mysrv.example.comlabels:job: workspaceinstance: mysrv.example.commetricsPath: /admin/metricstlsConfig:insecureSkipVerify: falsescheme: HTTPS---apiVersion: monitoring.coreos.com/v1alpha1kind: ScrapeConfigmetadata:name: templatenamespace: monitoringlabels:prometheus: system-monitoring-prometheusspec:scrapeInterval: 30sstaticConfigs:- targets:- mysrv.example.comlabels:job: templateinstance: mysrv.example.commetricsPath: /template/metricstlsConfig:insecureSkipVerify: falsescheme: HTTPS---apiVersion: monitoring.coreos.com/v1alpha1kind: ScrapeConfigmetadata:name: automationnamespace: monitoringlabels:prometheus: system-monitoring-prometheusapp: kube-prometheus-stackspec:scrapeInterval: 30sstaticConfigs:- targets:- mysrv.example.comlabels:job: automationinstance: mysrv.example.commetricsPath: /automation/metricstlsConfig:insecureSkipVerify: falsescheme: HTTPS---apiVersion: monitoring.coreos.com/v1alpha1kind: ScrapeConfigmetadata:name: gitintegrationnamespace: monitoringlabels:prometheus: system-monitoring-prometheusrelease: kube-prometheus-stackapp: kube-prometheus-stackspec:scrapeInterval: 30sstaticConfigs:- targets:- mysrv.example.comlabels:job: gitintegrationinstance: mysrv.example.commetricsPath: /vcs/metricstlsConfig:insecureSkipVerify: falsescheme: HTTPS---apiVersion: monitoring.coreos.com/v1alpha1kind: ScrapeConfigmetadata:name: historynamespace: monitoringlabels:prometheus: system-monitoring-prometheusspec:scrapeInterval: 30sstaticConfigs:- targets:- mysrv.example.comlabels:job: historyinstance: mysrv.example.commetricsPath: /history/metricstlsConfig:insecureSkipVerify: truescheme: HTTPS---apiVersion: monitoring.coreos.com/v1alpha1kind: ScrapeConfigmetadata:name: webhooknamespace: monitoringlabels:prometheus: system-monitoring-prometheusspec:scrapeInterval: 30sstaticConfigs:- targets:- mysrv.example.comlabels:job: webhookinstance: mysrv.example.commetricsPath: /webhook/metricstlsConfig:insecureSkipVerify: falsescheme: HTTPS---apiVersion: monitoring.coreos.com/v1alpha1kind: ScrapeConfigmetadata:name: commentnamespace: monitoringlabels:prometheus: system-monitoring-prometheusspec:scrapeInterval: 30sstaticConfigs:- targets:- mysrv.example.comlabels:job: commentinstance: mysrv.example.commetricsPath: /comments/metricstlsConfig:insecureSkipVerify: falsescheme: HTTPS---apiVersion: monitoring.coreos.com/v1alpha1kind: ScrapeConfigmetadata:name: notificationnamespace: monitoringlabels:prometheus: system-monitoring-prometheusspec:scrapeInterval: 30sstaticConfigs:- targets:- mysrv.example.comlabels:job: notificationinstance: mysrv.example.commetricsPath: /notifications/metricstlsConfig:insecureSkipVerify: falsescheme: HTTPS---apiVersion: monitoring.coreos.com/v1alpha1kind: ScrapeConfigmetadata:name: attachmentnamespace: monitoringlabels:prometheus: system-monitoring-prometheusspec:scrapeInterval: 30sstaticConfigs:- targets:- mysrv.example.comlabels:job: attachmentinstance: mysrv.example.commetricsPath: /attachments/metricstlsConfig:insecureSkipVerify: falsescheme: HTTPS---apiVersion: monitoring.coreos.com/v1alpha1kind: ScrapeConfigmetadata:name: workitemnamespace: monitoringlabels:prometheus: system-monitoring-prometheusspec:scrapeInterval: 30sstaticConfigs:- targets:- mysrv.example.comlabels:job: workiteminstance: mysrv.example.commetricsPath: /tasks/metricstlsConfig:insecureSkipVerify: falsescheme: HTTPS---apiVersion: monitoring.coreos.com/v1alpha1kind: ScrapeConfigmetadata:name: wikinamespace: monitoringlabels:prometheus: system-monitoring-prometheusspec:scrapeInterval: 30sstaticConfigs:- targets:- mysrv.example.comlabels:job: wikiinstance: mysrv.example.commetricsPath: /wiki/metricstlsConfig:insecureSkipVerify: falsescheme: HTTPS---apiVersion: monitoring.coreos.com/v1alpha1kind: ScrapeConfigmetadata:name: taskitemnamespace: monitoringlabels:prometheus: system-monitoring-prometheusspec:scrapeInterval: 30sstaticConfigs:- targets:- mysrv.example.comlabels:job: taskiteminstance: mysrv.example.commetricsPath: /personal-tasks/metricstlsConfig:insecureSkipVerify: falsescheme: HTTPS
Для включения метрик prometheus Проекты VK WorkSpace необходимо установить параметр .Values.metrics.enabled: true в values.yaml.
Автоматически будут созданы ServiceMonitor, с помощью которых prometheus будет забирать метрики.
Если в kubernetes не используется prometheus operator или нет crd,
то необходимо отключить создание ServiceMonitor .Values.metrics.serviceMonitor.enabled: false в values.yaml
и настроить с помощью ScrapeConfig.
Технический писатель: Белова Ирина
Была ли статья полезна?