Prometheus Exporter
Overview
sfPod scans all pods in the namespaces that it has access to for specific labels snappyflow/projectname and snappyflow/appname
If a pod is tagged with SnappyFlow labels, sfPod then looks for standard Prometheus annotations
Label Value prometheus.io/scrape If true, the pod is considered for Prometheus scraping, else it is excluded. prometheus.io/port This label defines a list of ports that sfPod will scan. sfPod will also apply the appropriate parser. If this label is empty, sfPod scans all exposed container ports. Default value is empty. prometheus.io/path Define the path as /metrics. Empty by default. If sfPod finds data on these ports, the data is scanned, parsed and sent to SnappyFlow
Monitoring pods using Prometheus exporter
Pre-requisites
- Ensure sfPod is running and has access privileges to namespace in which application pod is running
- Ensure sfPod has access to ports exposing Prometheus exporters
Enable access to Prometheus exporter
Add Prometheus exporter container as a sidecar in the application pod. Pls see example below for Prometheus exporter pod. sfPod needs to access the Prometheus exporter on the exported port, which should be exposed in pod’s service
After setup of Prometheus exporter container, please verify connectivity using:
curl service_ip: 9187
curl service_ip: 5432
Tag applications with Labels
Applying labels are key to monitoring in SnappyFLow. Endpoints are organized in a hierarchy as per the labels defined.
Add labels snappyflow/projectName and snappyflow/appName
if the application pods are already running, use the following kubectl commands to tag your application pods with the appropriate tags:
kubectl label pods <pod_name> snappyflow/projectname=<project_name> --namespace<appnamespace>
kubectl label pods <pod_name> snappyflow/appname=<app_name> --namespace<appnamespace>To automatically apply the right labels for the new pods which get created due to various reasons such as upgrades, restarts etc, apply labels to pod templates. If you are using helm chart, a best practice is to define labels in values.yaml and use the label parameters in pod template section of Deployment, StatefulSet, DaemonSet or other Kubernetes controller.
List of Prometheus exporters supported by sfPod
Plugins | Exporter Links | service_discovery_regex | Docker image |
---|---|---|---|
apache | Exporter Link | ["apache_accesses_total","apache_+"] | Docker image |
elasticsearch | Exporter Link | ["elasticsearch_+"] | Docker image |
haproxy | Exporter Link | ["haproxy_+"] | Docker image |
jmx | Exporter Link | ["jmx_exporter_build_info","jmx_+","java_lang_+"] | Docker image |
kafka-connect-j9 | Exporter Link | ["kafka_connect+","java_lang_+","java_lang_memorymanager_valid_j9+"] | Docker image |
kafka-connect | Exporter Link | ["kafka_connect+","java_lang_+","java_lang_garbagecollector_collectiontime_g1_young_generation"] | Docker image |
kafka-jmx | Exporter Link | ["kafka_server_+","kafka_network_+","java_lang_+"] | Docker image |
kafka-rest-j9 | Exporter Link | ["kafka_rest+","java_lang_+","java_lang_memorymanager_valid_j9+"] | Docker image |
kafka-rest | Exporter Link | ["kafka_rest+","java_lang_+","java_lang_garbagecollector_collectiontime_g1_young_generation"] | Docker image |
kafka | Exporter Link | ["kafka_topic_+"] | Docker image |
linux | Exporter Link | ["node_cpu_+","node_disk_+","node_procs_+"] | Docker image |
mongod | Exporter Link | ["mongodb_+"] | Docker image |
mysql | Exporter Link | ["mysql_global_+","mysql_version_+"] | Docker image |
nginx | Exporter Link | ["nginx_+"] | Docker image |
nodejs | No exporter. Using code instrumentation | ["nodejs_+"] | NodeJs |
postgres | Exporter Link | "pg_stat_+" | Docker image |
zookeeper-jmx | Exporter Link | ["zookeeper_+","java_lang_"] | Docker image |