Deploying a custom exporter for Prometheus
After configuring all the components, you need to deploy the exporter that Prometheus calls to get data from Redis; this service will be called service1
. Remember that Redis was being used to persist temporary data that comes from the Mosquitto topic on the far edge. Before deploying this service, let’s understand the exporter
container source code:
from flask import Response, Flask, request, jsonify import prometheus_client from prometheus_client import Gauge import redis import os import sys import json t = Gauge('weather_metric1', 'temperature') h = Gauge('weather_metric2', 'humidity') rhost = os.environ['REDIS_HOST'] rauth = os.environ['REDIS_AUTH'] stopic = os.environ['SENSOR_TOPIC'] r = redis.StrictRedis(host=rhost,\ port=6379,db=0,password=rauth,\ decode_responses...