Skip to main content

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

    LabelValue
    prometheus.io/scrapeIf true, the pod is considered for Prometheus scraping, else it is excluded.
    prometheus.io/portThis 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/pathDefine 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

  1. Ensure sfPod is running and has access privileges to namespace in which application pod is running 
  2. 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

PostgreSQL Statefulset YAML

PostgreSQL Service YAML

After setup of Prometheus exporter container, please verify connectivity using:

curl service_ip: 9187 
curl service_ip: 5432

Tag applications with Labels

note

Applying labels are key to monitoring in SnappyFLow. Endpoints are organized in a hierarchy as per the labels defined.

  1. Add labels snappyflow/projectName and snappyflow/appName 

    1. 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>
    2. 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

PluginsExporter Linksservice_discovery_regexDocker image
apacheExporter Link["apache_accesses_total","apache_+"]Docker image
elasticsearchExporter Link["elasticsearch_+"]Docker image
haproxyExporter Link["haproxy_+"]Docker image
jmxExporter Link["jmx_exporter_build_info","jmx_+","java_lang_+"]Docker image
kafka-connect-j9Exporter Link["kafka_connect+","java_lang_+","java_lang_memorymanager_valid_j9+"]Docker image
kafka-connectExporter Link["kafka_connect+","java_lang_+","java_lang_garbagecollector_collectiontime_g1_young_generation"]Docker image
kafka-jmxExporter Link["kafka_server_+","kafka_network_+","java_lang_+"]Docker image
kafka-rest-j9Exporter Link["kafka_rest+","java_lang_+","java_lang_memorymanager_valid_j9+"]Docker image
kafka-restExporter Link["kafka_rest+","java_lang_+","java_lang_garbagecollector_collectiontime_g1_young_generation"]Docker image
kafkaExporter Link["kafka_topic_+"]Docker image
linuxExporter Link["node_cpu_+","node_disk_+","node_procs_+"]Docker image
mongodExporter Link["mongodb_+"]Docker image
mysqlExporter Link["mysql_global_+","mysql_version_+"]Docker image
nginxExporter Link["nginx_+"]Docker image
nodejsNo exporter. Using code instrumentation["nodejs_+"]
postgresExporter Link"pg_stat_+"Docker image
zookeeper-jmxExporter Link["zookeeper_+","java_lang_"]Docker image