Spaces:
Sleeping
Sleeping
Commit ·
eb77a04
1
Parent(s): 2b6c9de
updated gradio and dash
Browse filesFiles changed (12)
- README.md+3
- app.pyDeleted-90
- dash/README.mdAdded+3
- dash/app.pyAdded+153
- gradio/README.mdAdded
- gradio/app.pyAdded+114
- node-red/README.mdAdded
- node-red/influxdb_line_protocol_conversion.jsAdded
- notebooks/tests.ipynbAdded+274
- streamlit/app.pyAdded+51
- telegraf/README.mdAdded
- telegraf/telegraf.confAdded+1687
123# Machine Monitoring Proof of Concept
## This repo includes a variety of experiments with using Gradio, Plotly Dash, and other tools to build machine monitoring apps and tools123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990import streamlit as stimport influxdb_clientfrom influxdb_client.client.write_api import SYNCHRONOUSimport paho.mqtt.client as mqttimport pandas as pdimport plotly.express as pxfrom datetime import datetime, timedeltaimport threadingimport json
# InfluxDB configurationINFLUXDB_URL = "http://localhost:8086"INFLUXDB_TOKEN = "your_influxdb_token"INFLUXDB_ORG = "your_org"INFLUXDB_BUCKET = "your_bucket"
# MQTT configurationMQTT_BROKER = "localhost"MQTT_PORT = 1883MQTT_TOPIC = "your/mqtt/topic"
# Initialize InfluxDB clientinfluxdb_client = influxdb_client.InfluxDBClient( url=INFLUXDB_URL, token=INFLUXDB_TOKEN, org=INFLUXDB_ORG)
# Initialize MQTT clientmqtt_client = mqtt.Client()
# Streamlit appdef main(): st.title("Data Visualization Dashboard")
# InfluxDB Query and Visualization st.header("Historical Data from InfluxDB") query = ''' from(bucket:"your_bucket") |> range(start: -1h) |> filter(fn: (r) => r._measurement == "your_measurement") |> aggregateWindow(every: 1m, fn: mean) ''' result = query_influxdb(query) if result: st.line_chart(result)
# MQTT Streaming Data Visualization st.header("Live Streaming Data from MQTT") mqtt_data = st.empty()
# Start MQTT client in a separate thread threading.Thread(target=start_mqtt_client, daemon=True).start()
# Update MQTT data periodically while True: mqtt_data.line_chart(get_mqtt_data()) st.experimental_rerun()
def query_influxdb(query): query_api = influxdb_client.query_api() result = query_api.query_data_frame(query) if not result.empty: result.set_index('_time', inplace=True) return result[['_value']] return None
def on_message(client, userdata, message): payload = json.loads(message.payload.decode()) # Process and store MQTT data as needed # For simplicity, we'll just append it to a global list global mqtt_data_list mqtt_data_list.append(payload)
def start_mqtt_client(): mqtt_client.on_message = on_message mqtt_client.connect(MQTT_BROKER, MQTT_PORT) mqtt_client.subscribe(MQTT_TOPIC) mqtt_client.loop_forever()
def get_mqtt_data(): global mqtt_data_list df = pd.DataFrame(mqtt_data_list) df['timestamp'] = pd.to_datetime(df['timestamp']) df.set_index('timestamp', inplace=True) return df
if __name__ == "__main__": mqtt_data_list = [] main()123## Dash App
This is an initial experiment of using Plotly Dash for building a python-based dashboard for machine monitoring123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153import dashfrom dash import dcc, htmlfrom dash.dependencies import Input, Output, Stateimport plotly.graph_objects as goimport pandas as pdfrom influxdb_client_3 import InfluxDBClient3from datetime import datetimeimport osimport paho.mqtt.client as mqttimport threadingimport json
# Global variablesMAX_DATA_POINTS = 100 # Increased for better visibilityMQTT_BROKER = "broker.hivemq.com"MQTT_TOPIC = "test_fan/current"mqtt_data = [] # Global list to store incoming MQTT messages
# InfluxDB configurationINFLUXDB_URL = "https://us-east-1-1.aws.cloud2.influxdata.com/"INFLUXDB_TOKEN = os.getenv("INFLUXDB_TOKEN")INFLUXDB_ORG = "dd7895c825a7c36a"INFLUXDB_BUCKET = "machine_monitoring"influx_client = InfluxDBClient3(host=INFLUXDB_URL, token=INFLUXDB_TOKEN, org=INFLUXDB_ORG, database="machine_monitoring")
# MQTT Client setupclient = mqtt.Client()
def on_connect(client, userdata, flags, rc): if rc == 0: print("Connected to MQTT Broker!") client.subscribe(MQTT_TOPIC) else: print(f"Failed to connect, return code {rc}")
def on_message(client, userdata, msg): global mqtt_data try: # Parse the message payload payload = float(msg.payload.decode('utf-8')) new_point = { "timestamp": msg.timestamp, "current": payload, "datetime": datetime.now().strftime('%Y-%m-%d %H:%M:%S') } mqtt_data.append(new_point) if len(mqtt_data) > MAX_DATA_POINTS: mqtt_data = mqtt_data[-MAX_DATA_POINTS:] print(f"Received MQTT data: {new_point}") except Exception as e: print(f"Error processing MQTT message: {e}")
def start_mqtt_client(): try: client.on_connect = on_connect client.on_message = on_message client.connect(MQTT_BROKER, 1883, 60) client.loop_start() # Start the MQTT client in a separate thread except Exception as e: print(f"Error starting MQTT client: {e}")
# Start MQTT client in a separate threadmqtt_thread = threading.Thread(target=start_mqtt_client)mqtt_thread.daemon = Truemqtt_thread.start()
# Initialize the Dash appapp = dash.Dash(__name__)
# Layoutapp.layout = html.Div([ html.H1("MQTT and InfluxDB Data Visualization"), html.Div([ html.H2("MQTT Data Visualization"), html.P(f"Listening to MQTT topic: {MQTT_TOPIC}"), dcc.Graph(id='mqtt-chart'), html.Div(id='mqtt-debug'), # Add a debug div dcc.Interval(id='mqtt-interval', interval=1000, n_intervals=0) # Add interval for regular updates ]), html.Div([ html.H2("InfluxDB Data Visualization"), dcc.Graph(id='influxdb-chart'), dcc.Interval(id='influxdb-interval', interval=300000, n_intervals=0) # Update every 5 minutes ])])
# Callback for MQTT chart and debug info@app.callback( [Output('mqtt-chart', 'figure'), Output('mqtt-debug', 'children')], [Input('mqtt-interval', 'n_intervals')])def update_mqtt_chart(n): global mqtt_data if not mqtt_data: return dash.no_update, "No MQTT data received yet." df = pd.DataFrame(mqtt_data) fig = go.Figure() fig.add_trace(go.Scatter( x=df['datetime'], y=df['current'], mode='lines+markers' )) fig.update_layout( title="MQTT Data Visualization", xaxis_title="Timestamp", yaxis_title="Current" ) debug_info = f"Last MQTT data point: {mqtt_data[-1]}" return fig, debug_info
# Callback for InfluxDB chart@app.callback( Output('influxdb-chart', 'figure'), Input('influxdb-interval', 'n_intervals'))def update_influxdb_chart(n): try: df = query_influxdb() fig = go.Figure() fig.add_trace(go.Scatter( x=df['time'], y=df['current'], mode='lines+markers' )) fig.update_layout( title="InfluxDB Data Visualization", xaxis_title="Time", yaxis_title="Current" ) return fig except Exception as e: print(f"Error querying InfluxDB: {e}") return dash.no_update
def query_influxdb(): try: query = ''' SELECT * FROM "fan" WHERE time >= now() - interval '2 week' ''' table = influx_client.query(query=query, language="sql") df = table.to_pandas().sort_values(by="time") return df except Exception as e: print(f"Error querying InfluxDB: {e}") return pd.DataFrame() # Return empty DataFrame on error
if __name__ == '__main__': app.run_server(debug=True)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114import gradio as grimport paho.mqtt.client as mqttimport pandas as pdimport timefrom influxdb_client_3 import InfluxDBClient3import threadingfrom datetime import datetimeimport plotly.express as pximport plotly.graph_objects as goimport os
# Global variablesdata_points = []MAX_DATA_POINTS = 10
# InfluxDB configurationINFLUXDB_URL = "https://us-east-1-1.aws.cloud2.influxdata.com/"INFLUXDB_TOKEN = os.getenv("INFLUXDB_TOKEN")INFLUXDB_ORG = "dd7895c825a7c36a"INFLUXDB_BUCKET = "machine_monitoring"influx_client = InfluxDBClient3(host=INFLUXDB_URL, token=INFLUXDB_TOKEN, org=INFLUXDB_ORG,database="machine_monitoring")
query = ''' SELECT * FROM "fan" WHERE time >= now() - interval '2 week' '''
# MQTT setupMQTT_BROKER = "broker.hivemq.com"MQTT_TOPIC = "test_fan/current"
def query_influxdb(query): table = influx_client.query(query=query, language="sql") df = table.to_pandas().sort_values(by="time") return df
def query_influxdb_gr(): query = ''' SELECT * FROM "fan" WHERE time >= now() - interval '2 week' ''' table = influx_client.query(query=query, language="sql") df = table.to_pandas().sort_values(by="time") return df
# Callback when a message is received from the serverdef on_message(client, userdata, message): global data_points try: payload = message.payload.decode() value = float(payload) # Assume the payload is a single float value data_points.append({"timestamp": time.time(), "current": value, "datetime": datetime.now().strftime('%H:%M:%S')}) # Keep only the last MAX_DATA_POINTS if len(data_points) > MAX_DATA_POINTS: data_points.pop(0) # Remove the oldest data point except ValueError: print(f"Received invalid payload: {payload}")
# Set up MQTT clientclient = mqtt.Client(client_id="gradio_client", protocol=mqtt.MQTTv311)client.on_message = on_messageclient.connect(MQTT_BROKER, 1883, 60)client.subscribe(MQTT_TOPIC)
# Start MQTT loop in a separate threadmqtt_thread = threading.Thread(target=client.loop_start)mqtt_thread.start()
# Gradio componentsdef update_mqtt_live_data(): # Convert timestamps to formatted time strings df = pd.DataFrame(data_points) return df
# Gradio componentsdef update_chart(): fig = go.Figure() fig.add_trace(go.Scatter( x=[point["timestamp"] for point in data_points], y=[point["value"] for point in data_points], mode='lines+markers' )) fig.update_layout( title="MQTT Data Visualization", xaxis_title="Timestamp", yaxis_title="Value" ) return fig
with gr.Blocks() as app: gr.Markdown("# MQTT Data Visualization") gr.Markdown(f"Listening to MQTT topic: {MQTT_TOPIC}")
line_plot = gr.LinePlot(update_mqtt_live_data, label="MQTT", x="datetime", y="current", every=1)
#plotly_plot = gr.Plot(make_figure(update_data), label="Plotly Chart", every=1)
gr.Markdown("# InfluxDB Data Visualization") line_plot = gr.LinePlot(query_influxdb_gr, label="InfluxDB", x="time", y="current", every=300)
gr.Markdown("# Plotly Data Visualization") plot = gr.Plot(update_chart, every=1) app.load(update_chart, None, plot)
# Launch the appapp.launch()123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274{ "cells": [ { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "import gradio as gr\n", "import paho.mqtt.client as mqtt\n", "import pandas as pd\n", "import time\n", "from influxdb_client_3 import InfluxDBClient3\n", "import threading\n", "from datetime import datetime\n", "import plotly.express as px\n", "import plotly.graph_objects as go\n", "import os" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [], "source": [ "INFLUXDB_URL = \"https://us-east-1-1.aws.cloud2.influxdata.com/\"\n", "\n", "INFLUXDB_ORG = \"dd7895c825a7c36a\"\n", "INFLUXDB_BUCKET = \"machine_monitoring\"\n", "influx_client = InfluxDBClient3(host=INFLUXDB_URL, token=INFLUXDB_TOKEN, org=INFLUXDB_ORG,database=\"machine_monitoring\")\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [], "source": [ "def query_influxdb(query):\n", " table = influx_client.query(query=query, language=\"sql\")\n", " df = table.to_pandas().sort_values(by=\"time\")\n", " return df" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [], "source": [ "\n", "query = '''\n", " SELECT *\n", " FROM \"fan\"\n", " WHERE time >= now() - interval '2 week'\n", " '''\n" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "data": { "text/html": [ "<div>\n", "<style scoped>\n", " .dataframe tbody tr th:only-of-type {\n", " vertical-align: middle;\n", " }\n", "\n", " .dataframe tbody tr th {\n", " vertical-align: top;\n", " }\n", "\n", " .dataframe thead th {\n", " text-align: right;\n", " }\n", "</style>\n", "<table border=\"1\" class=\"dataframe\">\n", " <thead>\n", " <tr style=\"text-align: right;\">\n", " <th></th>\n", " <th>current</th>\n", " <th>description</th>\n", " <th>host</th>\n", " <th>humidity</th>\n", " <th>location</th>\n", " <th>sensor</th>\n", " <th>temperature</th>\n", " <th>time</th>\n", " <th>topic</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>0</th>\n", " <td>0.00250</td>\n", " <td>Partly cloudy</td>\n", " <td>williamvanbuskirk-MacBook-Pro</td>\n", " <td>60.0</td>\n", " <td>Chicago</td>\n", " <td>S1</td>\n", " <td>72.5</td>\n", " <td>2024-10-06 01:09:17.800669</td>\n", " <td>test_fan</td>\n", " </tr>\n", " <tr>\n", " <th>1</th>\n", " <td>0.00226</td>\n", " <td>Partly cloudy</td>\n", " <td>williamvanbuskirk-MacBook-Pro</td>\n", " <td>60.0</td>\n", " <td>Chicago</td>\n", " <td>S1</td>\n", " <td>72.5</td>\n", " <td>2024-10-06 01:09:18.801087</td>\n", " <td>test_fan</td>\n", " </tr>\n", " <tr>\n", " <th>2</th>\n", " <td>0.00214</td>\n", " <td>Partly cloudy</td>\n", " <td>williamvanbuskirk-MacBook-Pro</td>\n", " <td>60.0</td>\n", " <td>Chicago</td>\n", " <td>S1</td>\n", " <td>72.5</td>\n", " <td>2024-10-06 01:09:19.841504</td>\n", " <td>test_fan</td>\n", " </tr>\n", " <tr>\n", " <th>3</th>\n", " <td>0.00190</td>\n", " <td>Partly cloudy</td>\n", " <td>williamvanbuskirk-MacBook-Pro</td>\n", " <td>60.0</td>\n", " <td>Chicago</td>\n", " <td>S1</td>\n", " <td>72.5</td>\n", " <td>2024-10-06 01:09:21.296156</td>\n", " <td>test_fan</td>\n", " </tr>\n", " <tr>\n", " <th>4</th>\n", " <td>0.00166</td>\n", " <td>Partly cloudy</td>\n", " <td>williamvanbuskirk-MacBook-Pro</td>\n", " <td>60.0</td>\n", " <td>Chicago</td>\n", " <td>S1</td>\n", " <td>72.5</td>\n", " <td>2024-10-06 01:09:22.797416</td>\n", " <td>test_fan</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "</div>" ], "text/plain": [ " current description host humidity location \\\n", "0 0.00250 Partly cloudy williamvanbuskirk-MacBook-Pro 60.0 Chicago \n", "1 0.00226 Partly cloudy williamvanbuskirk-MacBook-Pro 60.0 Chicago \n", "2 0.00214 Partly cloudy williamvanbuskirk-MacBook-Pro 60.0 Chicago \n", "3 0.00190 Partly cloudy williamvanbuskirk-MacBook-Pro 60.0 Chicago \n", "4 0.00166 Partly cloudy williamvanbuskirk-MacBook-Pro 60.0 Chicago \n", "\n", " sensor temperature time topic \n", "0 S1 72.5 2024-10-06 01:09:17.800669 test_fan \n", "1 S1 72.5 2024-10-06 01:09:18.801087 test_fan \n", "2 S1 72.5 2024-10-06 01:09:19.841504 test_fan \n", "3 S1 72.5 2024-10-06 01:09:21.296156 test_fan \n", "4 S1 72.5 2024-10-06 01:09:22.797416 test_fan " ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = query_influxdb(query)\n", "\n", "df.head()" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [], "source": [ "table = influx_client.query(query=query, language=\"sql\")" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "pyarrow.Table\n", "current: double\n", "description: string\n", "host: string\n", "humidity: double\n", "location: string\n", "sensor: string\n", "temperature: double\n", "time: timestamp[ns] not null\n", "topic: string\n", "----\n", "current: [[0.0025,0.0022600000000000003,0.0021400000000000004,0.0019,0.00166,...,0.0025000000000000005,0.00232,0.00202,0.00184,0.00184]]\n", "description: [[\"Partly cloudy\",\"Partly cloudy\",\"Partly cloudy\",\"Partly cloudy\",\"Partly cloudy\",...,\"Partly cloudy\",\"Partly cloudy\",\"Partly cloudy\",\"Partly cloudy\",\"Partly cloudy\"]]\n", "host: [[\"williamvanbuskirk-MacBook-Pro\",\"williamvanbuskirk-MacBook-Pro\",\"williamvanbuskirk-MacBook-Pro\",\"williamvanbuskirk-MacBook-Pro\",\"williamvanbuskirk-MacBook-Pro\",...,\"williamvanbuskirk-MacBook-Pro\",\"williamvanbuskirk-MacBook-Pro\",\"williamvanbuskirk-MacBook-Pro\",\"williamvanbuskirk-MacBook-Pro\",\"williamvanbuskirk-MacBook-Pro\"]]\n", "humidity: [[60,60,60,60,60,...,60,60,60,60,60]]\n", "location: [[\"Chicago\",\"Chicago\",\"Chicago\",\"Chicago\",\"Chicago\",...,\"Chicago\",\"Chicago\",\"Chicago\",\"Chicago\",\"Chicago\"]]\n", "sensor: [[\"S1\",\"S1\",\"S1\",\"S1\",\"S1\",...,\"S1\",\"S1\",\"S1\",\"S1\",\"S1\"]]\n", "temperature: [[72.5,72.5,72.5,72.5,72.5,...,72.5,72.5,72.5,72.5,72.5]]\n", "time: [[2024-10-06 01:09:17.800669000,2024-10-06 01:09:18.801087000,2024-10-06 01:09:19.841504000,2024-10-06 01:09:21.296156000,2024-10-06 01:09:22.797416000,...,2024-10-06 16:28:05.520067000,2024-10-06 16:28:06.522940000,2024-10-06 16:28:07.947039000,2024-10-06 16:28:08.941063000,2024-10-06 16:28:10.445205000]]\n", "topic: [[\"test_fan\",\"test_fan\",\"test_fan\",\"test_fan\",\"test_fan\",...,\"test_fan\",\"test_fan\",\"test_fan\",\"test_fan\",\"test_fan\"]]" ] }, "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "source": [ "table" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "base", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.9" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051import streamlit as stimport paho.mqtt.client as mqttimport pandas as pdimport plotly.graph_objs as gofrom influxdb_client_3 import InfluxDBClient3import osimport timeimport threading
# InfluxDB configurationINFLUXDB_URL = "https://us-east-1-1.aws.cloud2.influxdata.com/"INFLUXDB_TOKEN = os.getenv("INFLUXDB_TOKEN")INFLUXDB_ORG = "dd7895c825a7c36a"INFLUXDB_BUCKET = "machine_monitoring"
# MQTT configurationMQTT_BROKER = "broker.hivemq.com"MQTT_PORT = 1883MQTT_TOPIC = "test_fan"
# Global variablesdata_points = []MAX_DATA_POINTS = 100
# Initialize InfluxDB clientinflux_client = InfluxDBClient3(host=INFLUXDB_URL, token=INFLUXDB_TOKEN, org=INFLUXDB_ORG)
def query_influxdb(query): table = influx_client.query(query=query, database="machine_monitoring", language="sql") df = table.to_pandas().sort_values(by="time") return df
def main(): st.title("Data Visualization Dashboard")
# InfluxDB Query and Visualization st.header("Historical Data from InfluxDB") query = ''' SELECT * FROM "fan" WHERE time >= now() - interval '1 week' ''' df = query_influxdb(query) if not df.empty: st.line_chart(data=df, x='time', y='current') else: st.write("No historical data available for the past week.")
if __name__ == "__main__": main()1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687# Telegraf Configuration## Telegraf is entirely plugin driven. All metrics are gathered from the# declared inputs, and sent to the declared outputs.## Plugins must be declared in here to be active.# To deactivate a plugin, comment out the name and any variables.## Use 'telegraf -config telegraf.conf -test' to see what metrics a config# file would generate.## Environment variables can be used anywhere in this config file, simply surround# them with ${}. For strings the variable must be within quotes (ie, "${STR_VAR}"),# for numbers and booleans they should be plain (ie, ${INT_VAR}, ${BOOL_VAR})
# Global tags can be specified here in key="value" format.[global_tags] # dc = "us-east-1" # will tag all metrics with dc=us-east-1 # rack = "1a" ## Environment variables can be used as tags, and throughout the config file # user = "$USER"
# Configuration for telegraf agent[agent] ## Default data collection interval for all inputs interval = "10s" ## Rounds collection interval to 'interval' ## ie, if interval="10s" then always collect on :00, :10, :20, etc. round_interval = true
## Telegraf will send metrics to outputs in batches of at most ## metric_batch_size metrics. ## This controls the size of writes that Telegraf sends to output plugins. metric_batch_size = 1000
## Maximum number of unwritten metrics per output. Increasing this value ## allows for longer periods of output downtime without dropping metrics at the ## cost of higher maximum memory usage. metric_buffer_limit = 10000
## Collection jitter is used to jitter the collection by a random amount. ## Each plugin will sleep for a random time within jitter before collecting. ## This can be used to avoid many plugins querying things like sysfs at the ## same time, which can have a measurable effect on the system. collection_jitter = "0s"
## Collection offset is used to shift the collection by the given amount. ## This can be be used to avoid many plugins querying constraint devices ## at the same time by manually scheduling them in time. # collection_offset = "0s"
## Default flushing interval for all outputs. Maximum flush_interval will be ## flush_interval + flush_jitter flush_interval = "10s" ## Jitter the flush interval by a random amount. This is primarily to avoid ## large write spikes for users running a large number of telegraf instances. ## ie, a jitter of 5s and interval 10s means flushes will happen every 10-15s flush_jitter = "0s"
## Collected metrics are rounded to the precision specified. Precision is ## specified as an interval with an integer + unit (e.g. 0s, 10ms, 2us, 4s). ## Valid time units are "ns", "us" (or "µs"), "ms", "s". ## ## By default or when set to "0s", precision will be set to the same ## timestamp order as the collection interval, with the maximum being 1s: ## ie, when interval = "10s", precision will be "1s" ## when interval = "250ms", precision will be "1ms" ## ## Precision will NOT be used for service inputs. It is up to each individual ## service input to set the timestamp at the appropriate precision. precision = "0s"
## Log at debug level. # debug = false ## Log only error level messages. # quiet = false
## Log format controls the way messages are logged and can be one of "text", ## "structured" or, on Windows, "eventlog". # logformat = "text"
## Name of the file to be logged to or stderr if unset or empty. This ## setting is ignored for the "eventlog" format. # logfile = ""
## The logfile will be rotated after the time interval specified. When set ## to 0 no time based rotation is performed. Logs are rotated only when ## written to, if there is no log activity rotation may be delayed. # logfile_rotation_interval = "0h"
## The logfile will be rotated when it becomes larger than the specified ## size. When set to 0 no size based rotation is performed. # logfile_rotation_max_size = "0MB"
## Maximum number of rotated archives to keep, any older logs are deleted. ## If set to -1, no archives are removed. # logfile_rotation_max_archives = 5
## Pick a timezone to use when logging or type 'local' for local time. ## Example: America/Chicago # log_with_timezone = ""
## Override default hostname, if empty use os.Hostname() # hostname = "" ## If set to true, do no set the "host" tag in the telegraf agent. # omit_hostname = false
## Method of translating SNMP objects. Can be "netsnmp" (deprecated) which ## translates by calling external programs snmptranslate and snmptable, ## or "gosmi" which translates using the built-in gosmi library. # snmp_translator = "netsnmp"
## Name of the file to load the state of plugins from and store the state to. ## If uncommented and not empty, this file will be used to save the state of ## stateful plugins on termination of Telegraf. If the file exists on start, ## the state in the file will be restored for the plugins. # statefile = ""
## Flag to skip running processors after aggregators ## By default, processors are run a second time after aggregators. Changing ## this setting to true will skip the second run of processors. # skip_processors_after_aggregators = false
################################################################################ SECRETSTORE PLUGINS ################################################################################
# # Secret-store to access Docker Secrets# [[secretstores.docker]]# ## Unique identifier for the secretstore.# ## This id can later be used in plugins to reference the secrets# ## in this secret-store via @{<id>:<secret_key>} (mandatory)# id = "docker_secretstore"## ## Default Path to directory where docker stores the secrets file# ## Current implementation in docker compose v2 only allows the following# ## value for the path where the secrets are mounted at runtime# # path = "/run/secrets"## ## Allow dynamic secrets that are updated during runtime of telegraf# ## Dynamic Secrets work only with `file` or `external` configuration# ## in `secrets` section of the `docker-compose.yml` file# # dynamic = false
# # Read secrets from a HTTP endpoint# [[secretstores.http]]# ## Unique identifier for the secret-store.# ## This id can later be used in plugins to reference the secrets# ## in this secret-store via @{<id>:<secret_key>} (mandatory)# id = "secretstore"## ## URLs from which to read the secrets# url = "http://localhost/secrets"## ## Optional HTTP headers# # headers = {"X-Special-Header" = "Special-Value"}## ## Optional Token for Bearer Authentication via# ## "Authorization: Bearer <token>" header# # token = "your-token"## ## Optional Credentials for HTTP Basic Authentication# # username = "username"# # password = "pa$$word"## ## OAuth2 Client Credentials. The options 'client_id', 'client_secret', and 'token_url' are required to use OAuth2.# # client_id = "clientid"# # client_secret = "secret"# # token_url = "https://indentityprovider/oauth2/v1/token"# # scopes = ["urn:opc:idm:__myscopes__"]## ## HTTP Proxy support# # use_system_proxy = false# # http_proxy_url = ""## ## Optional TLS Config# # tls_ca = "/etc/telegraf/ca.pem"# # tls_cert = "/etc/telegraf/cert.pem"# # tls_key = "/etc/telegraf/key.pem"# ## Minimal TLS version to accept by the client# # tls_min_version = "TLS12"# ## Use TLS but skip chain & host verification# # insecure_skip_verify = false## ## Optional Cookie authentication# # cookie_auth_url = "https://localhost/authMe"# # cookie_auth_method = "POST"# # cookie_auth_username = "username"# # cookie_auth_password = "pa$$word"# # cookie_auth_headers = { Content-Type = "application/json", X-MY-HEADER = "hello" }# # cookie_auth_body = '{"username": "user", "password": "pa$$word", "authenticate": "me"}'# ## When unset or set to zero the authentication will only happen once# ## and will never renew the cookie. Set to a suitable duration if you# ## require cookie renewal!# # cookie_auth_renewal = "0s"## ## Amount of time allowed to complete the HTTP request# # timeout = "5s"## ## List of success status codes# # success_status_codes = [200]## ## JSONata expression to transform the server response into a# ## { "secret name": "secret value", ... }# ## form. See https://jsonata.org for more information and a playground.# # transformation = ''## ## Cipher used to decrypt the secrets.# ## In case your secrets are transmitted in an encrypted form, you need# ## to specify the cipher used and provide the corresponding configuration.# ## Please refer to https://github.com/influxdata/telegraf/blob/master/plugins/secretstores/http/README.md# ## for supported values.# # cipher = "none"## ## AES cipher parameters# # [secretstores.http.aes]# # ## Key (hex-encoded) and initialization-vector (IV) for the decryption.# # ## In case the key (and IV) is derived from a password, the values can# # ## be omitted.# # key = ""# # init_vector = ""# ## # ## Parameters for password-based-key derivation.# # ## These parameters must match the encryption side to derive the same# # ## key on both sides!# # # kdf_algorithm = "PBKDF2-HMAC-SHA256"# # # password = ""# # # salt = ""# # # iterations = 0
# # File based Javascript Object Signing and Encryption based secret-store# [[secretstores.jose]]# ## Unique identifier for the secret-store.# ## This id can later be used in plugins to reference the secrets# ## in this secret-store via @{<id>:<secret_key>} (mandatory)# id = "secretstore"## ## Directory for storing the secrets# path = "/etc/telegraf/secrets"## ## Password to access the secrets.# ## If no password is specified here, Telegraf will prompt for it at startup time.# # password = ""
# # Secret-store to retrieve and maintain tokens from various OAuth2 services# [[secretstores.oauth2]]# ## Unique identifier for the secret-store.# ## This id can later be used in plugins to reference the secrets# ## in this secret-store via @{<id>:<secret_key>} (mandatory)# id = "secretstore"## ## Service to retrieve the token(s) from# ## Currently supported services are "custom", "auth0" and "AzureAD"# # service = "custom"## ## Setting to overwrite the queried token-endpoint# ## This setting is optional for some services but mandatory for others such# ## as "custom" or "auth0". Please check the documentation at# ## https://github.com/influxdata/telegraf/blob/master/plugins/secretstores/oauth2/README.md# # token_endpoint = ""## ## Tenant ID for the AzureAD service# # tenant_id = ""## ## Minimal remaining time until the token expires# ## If a token expires less than the set duration in the future, the token is# ## renewed. This is useful to avoid race-condition issues where a token is# ## still valid, but isn't when the request reaches the API endpoint of# ## your service using the token.# # token_expiry_margin = "1s"## ## Section for defining a token secret# [[secretstores.oauth2.token]]# ## Unique secret-key used for referencing the token via @{<id>:<secret_key>}# key = ""# ## Client-ID and secret for the 2-legged OAuth flow# client_id = ""# client_secret = ""# ## Scopes to send in the request# # scopes = []## ## Additional (optional) parameters to include in the token request# ## This might for example include the "audience" parameter required for# ## auth0.# # [secretstores.oauth2.token.parameters]# # audience = ""
# # Operating System native secret-store# [[secretstores.os]]# ## Unique identifier for the secret-store.# ## This id can later be used in plugins to reference the secrets# ## in this secret-store via @{<id>:<secret_key>} (mandatory)# id = "secretstore"## ## Keyring Name & Collection# ## * Linux: keyring name used for the secrets, collection is unused# ## * macOS: keyring specifies the macOS' Keychain name and collection is an# ## optional Keychain service name# ## * Windows: keys follow a fixed pattern in the form# ## `<collection>:<keyring>:<key_name>`. Please keep this in mind when# ## creating secrets with the Windows credential tool.# # keyring = "telegraf"# # collection = ""## ## macOS Keychain password# ## If no password is specified here, Telegraf will prompt for it at startup# ## time.# # password = ""## ## Allow dynamic secrets that are updated during runtime of telegraf# # dynamic = false
# Configuration for sending metrics to InfluxDB 2.0[[outputs.influxdb_v2]] ## The URLs of the InfluxDB cluster nodes. ## ## Multiple URLs can be specified for a single cluster, only ONE of the ## urls will be written to each interval. ## ex: urls = ["https://us-west-2-1.aws.cloud2.influxdata.com"] urls = ["http://127.0.0.1:8086"]
## Local address to bind when connecting to the server ## If empty or not set, the local address is automatically chosen. # local_address = ""
## Token for authentication. token = ""
## Organization is the name of the organization you wish to write to. organization = ""
## Destination bucket to write into. bucket = ""
## The value of this tag will be used to determine the bucket. If this ## tag is not set the 'bucket' option is used as the default. # bucket_tag = ""
## If true, the bucket tag will not be added to the metric. # exclude_bucket_tag = false
## Timeout for HTTP messages. # timeout = "5s"
## Additional HTTP headers # http_headers = {"X-Special-Header" = "Special-Value"}
## HTTP Proxy override, if unset values the standard proxy environment ## variables are consulted to determine which proxy, if any, should be used. # http_proxy = "http://corporate.proxy:3128"
## HTTP User-Agent # user_agent = "telegraf"
## Content-Encoding for write request body, can be set to "gzip" to ## compress body or "identity" to apply no encoding. # content_encoding = "gzip"
## Enable or disable uint support for writing uints influxdb 2.0. # influx_uint_support = false
## When true, Telegraf will omit the timestamp on data to allow InfluxDB ## to set the timestamp of the data during ingestion. This is generally NOT ## what you want as it can lead to data points captured at different times ## getting omitted due to similar data. # influx_omit_timestamp = false
## HTTP/2 Timeouts ## The following values control the HTTP/2 client's timeouts. These settings ## are generally not required unless a user is seeing issues with client ## disconnects. If a user does see issues, then it is suggested to set these ## values to "15s" for ping timeout and "30s" for read idle timeout and ## retry. ## ## Note that the timer for read_idle_timeout begins at the end of the last ## successful write and not at the beginning of the next write. # ping_timeout = "0s" # read_idle_timeout = "0s"
## Optional TLS Config for use on HTTP connections. # tls_ca = "/etc/telegraf/ca.pem" # tls_cert = "/etc/telegraf/cert.pem" # tls_key = "/etc/telegraf/key.pem" ## Use TLS but skip chain & host verification # insecure_skip_verify = false
################################################################################ PROCESSOR PLUGINS ################################################################################
# # Attach AWS EC2 metadata to metrics# [[processors.aws_ec2]]# ## Instance identity document tags to attach to metrics.# ## For more information see:# ## https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-identity-documents.html# ### ## Available tags:# ## * accountId# ## * architecture# ## * availabilityZone# ## * billingProducts# ## * imageId# ## * instanceId# ## * instanceType# ## * kernelId# ## * pendingTime# ## * privateIp# ## * ramdiskId# ## * region# ## * version# # imds_tags = []## ## EC2 instance tags retrieved with DescribeTags action.# ## In case tag is empty upon retrieval it's omitted when tagging metrics.# ## Note that in order for this to work, role attached to EC2 instance or AWS# ## credentials available from the environment must have a policy attached, that# ## allows ec2:DescribeTags.# ### ## For more information see:# ## https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeTags.html# # ec2_tags = []## ## Paths to instance metadata information to attach to the metrics.# ## Specify the full path without the base-path e.g. `tags/instance/Name`.# ### ## For more information see:# ## https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html# # metadata_paths = []## ## Allows to convert metadata tag-names to canonical names representing the# ## full path with slashes ('/') being replaces with underscores. By default,# ## only the last path element is used to name the tag.# # canonical_metadata_tags = false## ## Timeout for http requests made by against aws ec2 metadata endpoint.# # timeout = "10s"## ## ordered controls whether or not the metrics need to stay in the same order# ## this plugin received them in. If false, this plugin will change the order# ## with requests hitting cached results moving through immediately and not# ## waiting on slower lookups. This may cause issues for you if you are# ## depending on the order of metrics staying the same. If so, set this to true.# ## Keeping the metrics ordered may be slightly slower.# # ordered = false## ## max_parallel_calls is the maximum number of AWS API calls to be in flight# ## at the same time.# ## It's probably best to keep this number fairly low.# # max_parallel_calls = 10## ## cache_ttl determines how long each cached item will remain in the cache before# ## it is removed and subsequently needs to be queried for from the AWS API. By# ## default, no items are cached.# # cache_ttl = "0s"## ## tag_cache_size determines how many of the values which are found in imds_tags# ## or ec2_tags will be kept in memory for faster lookup on successive processing# ## of metrics. You may want to adjust this if you have excessively large numbers# ## of tags on your EC2 instances, and you are using the ec2_tags field. This# ## typically does not need to be changed when using the imds_tags field.# # tag_cache_size = 1000## ## log_cache_stats will emit a log line periodically to stdout with details of# ## cache entries, hits, misses, and evacuations since the last time stats were# ## emitted. This can be helpful in determining whether caching is being effective# ## in your environment. Stats are emitted every 30 seconds. By default, this# ## setting is disabled.
# # Apply metric modifications using override semantics.# [[processors.clone]]# ## All modifications on inputs and aggregators can be overridden:# # name_override = "new_name"# # name_prefix = "new_name_prefix"# # name_suffix = "new_name_suffix"## ## Tags to be added (all values must be strings)# # [processors.clone.tags]# # additional_tag = "tag_value"
# # Convert values to another metric value type# [[processors.converter]]# ## Tags to convert# ### ## The table key determines the target type, and the array of key-values# ## select the keys to convert. The array may contain globs.# ## <target-type> = [<tag-key>...]# [processors.converter.tags]# measurement = []# string = []# integer = []# unsigned = []# boolean = []# float = []## ## Optional tag to use as metric timestamp# # timestamp = []## ## Format of the timestamp determined by the tag above. This can be any of# ## "unix", "unix_ms", "unix_us", "unix_ns", or a valid Golang time format.# ## It is required, when using the timestamp option.# # timestamp_format = ""## ## Fields to convert# ### ## The table key determines the target type, and the array of key-values# ## select the keys to convert. The array may contain globs.# ## <target-type> = [<field-key>...]# [processors.converter.fields]# measurement = []# tag = []# string = []# integer = []# unsigned = []# boolean = []# float = []## ## Optional field to use as metric timestamp# # timestamp = []## ## Format of the timestamp determined by the field above. This can be any# ## of "unix", "unix_ms", "unix_us", "unix_ns", or a valid Golang time# ## format. It is required, when using the timestamp option.# # timestamp_format = ""
# # Dates measurements, tags, and fields that pass through this filter.# [[processors.date]]# ## New tag to create# tag_key = "month"## ## New field to create (cannot set both field_key and tag_key)# # field_key = "month"## ## Date format string, must be a representation of the Go "reference time"# ## which is "Mon Jan 2 15:04:05 -0700 MST 2006".# date_format = "Jan"## ## If destination is a field, date format can also be one of# ## "unix", "unix_ms", "unix_us", or "unix_ns", which will insert an integer field.# # date_format = "unix"## ## Offset duration added to the date string when writing the new tag.# # date_offset = "0s"## ## Timezone to use when creating the tag or field using a reference time# ## string. This can be set to one of "UTC", "Local", or to a location name# ## in the IANA Time Zone database.# ## example: timezone = "America/Los_Angeles"# # timezone = "UTC"
# # Filter metrics with repeating field values# [[processors.dedup]]# ## Maximum time to suppress output# dedup_interval = "600s"
# ## Set default fields on your metric(s) when they are nil or empty# [[processors.defaults]]# ## Ensures a set of fields always exists on your metric(s) with their# ## respective default value.# ## For any given field pair (key = default), if it's not set, a field# ## is set on the metric with the specified default.# ### ## A field is considered not set if it is nil on the incoming metric;# ## or it is not nil but its value is an empty string or is a string# ## of one or more spaces.# ## <target-field> = <value># [processors.defaults.fields]# field_1 = "bar"# time_idle = 0# is_error = true
# # Map enum values according to given table.# [[processors.enum]]# [[processors.enum.mapping]]# ## Name of the field to map. Globs accepted.# field = "status"## ## Name of the tag to map. Globs accepted.# # tag = "status"## ## Destination tag or field to be used for the mapped value. By default the# ## source tag or field is used, overwriting the original value.# dest = "status_code"## ## Default value to be used for all values not contained in the mapping# ## table. When unset and no match is found, the original field will remain# ## unmodified and the destination tag or field will not be created.# # default = 0## ## Table of mappings# [processors.enum.mapping.value_mappings]# green = 1# amber = 2# red = 3
# # Run executable as long-running processor plugin# [[processors.execd]]# ## One program to run as daemon.# ## NOTE: process and each argument should each be their own string# ## eg: command = ["/path/to/your_program", "arg1", "arg2"]# command = ["cat"]## ## Environment variables# ## Array of "key=value" pairs to pass as environment variables# ## e.g. "KEY=value", "USERNAME=John Doe",# ## "LD_LIBRARY_PATH=/opt/custom/lib64:/usr/local/libs"# # environment = []## ## Delay before the process is restarted after an unexpected termination# # restart_delay = "10s"## ## Serialization format for communicating with the executed program# ## Please note that the corresponding data-format must exist both in# ## parsers and serializers# # data_format = "influx"
# # Performs file path manipulations on tags and fields# [[processors.filepath]]# ## Treat the tag value as a path and convert it to its last element, storing the result in a new tag# # [[processors.filepath.basename]]# # tag = "path"# # dest = "basepath"## ## Treat the field value as a path and keep all but the last element of path, typically the path's directory# # [[processors.filepath.dirname]]# # field = "path"## ## Treat the tag value as a path, converting it to its the last element without its suffix# # [[processors.filepath.stem]]# # tag = "path"## ## Treat the tag value as a path, converting it to the shortest path name equivalent# ## to path by purely lexical processing# # [[processors.filepath.clean]]# # tag = "path"## ## Treat the tag value as a path, converting it to a relative path that is lexically# ## equivalent to the source path when joined to 'base_path'# # [[processors.filepath.rel]]# # tag = "path"# # base_path = "/var/log"## ## Treat the tag value as a path, replacing each separator character in path with a '/' character. Has only# ## effect on Windows# # [[processors.filepath.toslash]]# # tag = "path"
# # Filter metrics by the given criteria# [[processors.filter]]# ## Default action if no rule applies# # default = "pass"## ## Rules to apply on the incoming metrics (multiple rules are possible)# ## The rules are evaluated in order and the first matching rule is applied.# ## In case no rule matches the "default" is applied.# ## All filter criteria in a rule must apply for the rule to match the metric# ## i.e. the criteria are combined by a logical AND. If a criterion is# ## omitted it is NOT applied at all and ignored.# [[processors.filter.rule]]# ## List of metric names to match including glob expressions# # name = []## ## List of tag key/values pairs to match including glob expressions# ## ALL given tags keys must exist and at least one value must match# ## for the metric to match the rule.# # tags = {}## ## List of field keys to match including glob expressions# ## At least one field must exist for the metric to match the rule.# # fields = []## ## Action to apply for this rule# ## "pass" will keep the metric and pass it on, while "drop" will remove# ## the metric# # action = "drop"
# # Add a tag of the network interface name looked up over SNMP by interface number# [[processors.ifname]]# ## Name of tag holding the interface number# # tag = "ifIndex"## ## Name of output tag where service name will be added# # dest = "ifName"## ## Name of tag of the SNMP agent to request the interface name from# ## example: agent = "source"# # agent = "agent"## ## Timeout for each request.# # timeout = "5s"## ## SNMP version; can be 1, 2, or 3.# # version = 2## ## SNMP community string.# # community = "public"## ## Number of retries to attempt.# # retries = 3## ## The GETBULK max-repetitions parameter.# # max_repetitions = 10## ## SNMPv3 authentication and encryption options.# ### ## Security Name.# # sec_name = "myuser"# ## Authentication protocol; one of "MD5", "SHA", or "".# # auth_protocol = "MD5"# ## Authentication password.# # auth_password = "pass"# ## Security Level; one of "noAuthNoPriv", "authNoPriv", or "authPriv".# # sec_level = "authNoPriv"# ## Context Name.# # context_name = ""# ## Privacy protocol used for encrypted messages; one of "DES", "AES" or "".# # priv_protocol = ""# ## Privacy password used for encrypted messages.# # priv_password = ""## ## max_parallel_lookups is the maximum number of SNMP requests to# ## make at the same time.# # max_parallel_lookups = 100## ## ordered controls whether or not the metrics need to stay in the# ## same order this plugin received them in. If false, this plugin# ## may change the order when data is cached. If you need metrics to# ## stay in order set this to true. keeping the metrics ordered may# ## be slightly slower# # ordered = false## ## cache_ttl is the amount of time interface names are cached for a# ## given agent. After this period elapses if names are needed they# ## will be retrieved again.# # cache_ttl = "8h"
# # Lookup a key derived from metrics in a static file# [[processors.lookup]]# ## List of files containing the lookup-table# files = ["path/to/lut.json", "path/to/another_lut.json"]## ## Format of the lookup file(s)# ## Available formats are:# ## json -- JSON file with 'key: {tag-key: tag-value, ...}' mapping# ## csv_key_name_value -- CSV file with 'key,tag-key,tag-value,...,tag-key,tag-value' mapping# ## csv_key_values -- CSV file with a header containing tag-names and# ## rows with 'key,tag-value,...,tag-value' mappings# # format = "json"## ## Template for generating the lookup-key from the metric.# ## This is a Golang template (see https://pkg.go.dev/text/template) to# ## access the metric name (`{{.Name}}`), a tag value (`{{.Tag "name"}}`) or# ## a field value (`{{.Field "name"}}`).# key = '{{.Tag "host"}}'
# # Adds noise to numerical fields# [[processors.noise]]# ## Specified the type of the random distribution.# ## Can be "laplacian", "gaussian" or "uniform".# # type = "laplacian## ## Center of the distribution.# ## Only used for Laplacian and Gaussian distributions.# # mu = 0.0## ## Scale parameter for the Laplacian or Gaussian distribution# # scale = 1.0## ## Upper and lower bound of the Uniform distribution# # min = -1.0# # max = 1.0## ## Apply the noise only to numeric fields matching the filter criteria below.# ## Excludes takes precedence over includes.# # include_fields = []# # exclude_fields = []
# # Apply metric modifications using override semantics.# [[processors.override]]# ## All modifications on inputs and aggregators can be overridden:# # name_override = "new_name"# # name_prefix = "new_name_prefix"# # name_suffix = "new_name_suffix"## ## Tags to be added (all values must be strings)# # [processors.override.tags]# # additional_tag = "tag_value"
# # Parse a value in a specified field(s)/tag(s) and add the result in a new metric# [[processors.parser]]# ## The name of the fields whose value will be parsed.# parse_fields = ["message"]## ## Fields to base64 decode.# ## These fields do not need to be specified in parse_fields.# ## Fields specified here will have base64 decode applied to them.# # parse_fields_base64 = []## ## The name of the tags whose value will be parsed.# # parse_tags = []## ## If true, incoming metrics are not emitted.# # drop_original = false## ## Merge Behavior# ## Only has effect when drop_original is set to false. Possible options# ## include:# ## * override: emitted metrics are merged by overriding the original metric# ## using the newly parsed metrics, but retains the original metric# ## timestamp.# ## * override-with-timestamp: the same as "override", but the timestamp is# ## set based on the new metrics if present.# # merge = ""## ## The dataformat to be read from files# ## Each data format has its own unique set of configuration options, read# ## more about them here:# ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md# data_format = "influx"
# # Rotate a single valued metric into a multi field metric# [[processors.pivot]]# ## Tag to use for naming the new field.# tag_key = "name"# ## Field to use as the value of the new field.# value_key = "value"
# # Given a tag/field of a TCP or UDP port number, add a tag/field of the service name looked up in the system services file# [[processors.port_name]]# ## Name of tag holding the port number# # tag = "port"# ## Or name of the field holding the port number# # field = "port"## ## Name of output tag or field (depending on the source) where service name will be added# # dest = "service"## ## Default tcp or udp# # default_protocol = "tcp"## ## Tag containing the protocol (tcp or udp, case-insensitive)# # protocol_tag = "proto"## ## Field containing the protocol (tcp or udp, case-insensitive)# # protocol_field = "proto"
# # Print all metrics that pass through this filter.# [[processors.printer]]# ## Maximum line length in bytes. Useful only for debugging.# # influx_max_line_bytes = 0## ## When true, fields will be output in ascending lexical order. Enabling# ## this option will result in decreased performance and is only recommended# ## when you need predictable ordering while debugging.# # influx_sort_fields = false## ## When true, Telegraf will output unsigned integers as unsigned values,# ## i.e.: `42u`. You will need a version of InfluxDB supporting unsigned# ## integer values. Enabling this option will result in field type errors if# ## existing data has been written.# # influx_uint_support = false## ## When true, Telegraf will omit the timestamp on data to allow InfluxDB# ## to set the timestamp of the data during ingestion. This is generally NOT# ## what you want as it can lead to data points captured at different times# ## getting omitted due to similar data.# # influx_omit_timestamp = false
# # Transforms tag and field values as well as measurement, tag and field names with regex pattern# [[processors.regex]]# namepass = ["nginx_requests"]## ## Tag value conversion(s). Multiple instances are allowed.# [[processors.regex.tags]]# ## Tag(s) to process with optional glob expressions such as '*'.# key = "resp_code"# ## Regular expression to match the tag value. If the value doesn't# ## match the tag is ignored.# pattern = "^(\\d)\\d\\d$"# ## Replacement expression defining the value of the target tag. You can# ## use regexp groups or named groups e.g. ${1} references the first group.# replacement = "${1}xx"# ## Name of the target tag defaulting to 'key' if not specified.# ## In case of wildcards being used in `key` the currently processed# ## tag-name is used as target.# # result_key = "method"# ## Appends the replacement to the target tag instead of overwriting it when# ## set to true.# # append = false## ## Field value conversion(s). Multiple instances are allowed.# [[processors.regex.fields]]# ## Field(s) to process with optional glob expressions such as '*'.# key = "request"# ## Regular expression to match the field value. If the value doesn't# ## match or the field doesn't contain a string the field is ignored.# pattern = "^/api(?P<method>/[\\w/]+)\\S*"# ## Replacement expression defining the value of the target field. You can# ## use regexp groups or named groups e.g. ${method} references the group# ## named "method".# replacement = "${method}"# ## Name of the target field defaulting to 'key' if not specified.# ## In case of wildcards being used in `key` the currently processed# ## field-name is used as target.# # result_key = "method"## ## Rename metric fields# [[processors.regex.field_rename]]# ## Regular expression to match on the field name# pattern = "^search_(\\w+)d$"# ## Replacement expression defining the name of the new field# replacement = "${1}"# ## If the new field name already exists, you can either "overwrite" the# ## existing one with the value of the renamed field OR you can "keep"# ## both the existing and source field.# # result_key = "keep"## ## Rename metric tags# [[processors.regex.tag_rename]]# ## Regular expression to match on a tag name# pattern = "^search_(\\w+)d$"# ## Replacement expression defining the name of the new tag# replacement = "${1}"# ## If the new tag name already exists, you can either "overwrite" the# ## existing one with the value of the renamed tag OR you can "keep"# ## both the existing and source tag.# # result_key = "keep"## ## Rename metrics# [[processors.regex.metric_rename]]# ## Regular expression to match on an metric name# pattern = "^search_(\\w+)d$"# ## Replacement expression defining the new name of the metric# replacement = "${1}"
# # Rename measurements, tags, and fields that pass through this filter.# [[processors.rename]]# ## Specify one sub-table per rename operation.# [[processors.rename.replace]]# measurement = "network_interface_throughput"# dest = "throughput"## [[processors.rename.replace]]# tag = "hostname"# dest = "host"## [[processors.rename.replace]]# field = "lower"# dest = "min"## [[processors.rename.replace]]# field = "upper"# dest = "max"
# # ReverseDNS does a reverse lookup on IP addresses to retrieve the DNS name# [[processors.reverse_dns]]# ## For optimal performance, you may want to limit which metrics are passed to this# ## processor. eg:# ## namepass = ["my_metric_*"]## ## cache_ttl is how long the dns entries should stay cached for.# ## generally longer is better, but if you expect a large number of diverse lookups# ## you'll want to consider memory use.# cache_ttl = "24h"## ## lookup_timeout is how long should you wait for a single dns request to respond.# ## this is also the maximum acceptable latency for a metric travelling through# ## the reverse_dns processor. After lookup_timeout is exceeded, a metric will# ## be passed on unaltered.# ## multiple simultaneous resolution requests for the same IP will only make a# ## single rDNS request, and they will all wait for the answer for this long.# lookup_timeout = "3s"## ## max_parallel_lookups is the maximum number of dns requests to be in flight# ## at the same time. Requesting hitting cached values do not count against this# ## total, and neither do mulptiple requests for the same IP.# ## It's probably best to keep this number fairly low.# max_parallel_lookups = 10## ## ordered controls whether or not the metrics need to stay in the same order# ## this plugin received them in. If false, this plugin will change the order# ## with requests hitting cached results moving through immediately and not# ## waiting on slower lookups. This may cause issues for you if you are# ## depending on the order of metrics staying the same. If so, set this to true.# ## keeping the metrics ordered may be slightly slower.# ordered = false## [[processors.reverse_dns.lookup]]# ## get the ip from the field "source_ip", and put the result in the field "source_name"# field = "source_ip"# dest = "source_name"## [[processors.reverse_dns.lookup]]# ## get the ip from the tag "destination_ip", and put the result in the tag# ## "destination_name".# tag = "destination_ip"# dest = "destination_name"## ## If you would prefer destination_name to be a field instead, you can use a# ## processors.converter after this one, specifying the order attribute.
# # Add the S2 Cell ID as a tag based on latitude and longitude fields# [[processors.s2geo]]# ## The name of the lat and lon fields containing WGS-84 latitude and# ## longitude in decimal degrees.# # lat_field = "lat"# # lon_field = "lon"## ## New tag to create# # tag_key = "s2_cell_id"## ## Cell level (see https://s2geometry.io/resources/s2cell_statistics.html)# # cell_level = 9
# # Scale values with a predefined range to a different output range.# [[processors.scale]]# ## It is possible to define multiple different scaling that can be applied# ## do different sets of fields. Each scaling expects the following# ## arguments:# ## - input_minimum: Minimum expected input value# ## - input_maximum: Maximum expected input value# ## - output_minimum: Minimum desired output value# ## - output_maximum: Maximum desired output value# ## alternatively you can specify a scaling with factor and offset# ## - factor: factor to scale the input value with# ## - offset: additive offset for value after scaling# ## - fields: a list of field names (or filters) to apply this scaling to## ## Example: Scaling with minimum and maximum values# # [[processors.scale.scaling]]# # input_minimum = 0.0# # input_maximum = 1.0# # output_minimum = 0.0# # output_maximum = 100.0# # fields = ["temperature1", "temperature2"]## ## Example: Scaling with factor and offset# # [[processors.scale.scaling]]# # factor = 10.0# # offset = -5.0# # fields = ["voltage*"]
# # Lookup extra tags via SNMP based on the table index# [[processors.snmp_lookup]]# ## Name of tag of the SNMP agent to do the lookup on# # agent_tag = "source"## ## Name of tag holding the table row index# # index_tag = "index"## ## Timeout for each request.# # timeout = "5s"## ## SNMP version; can be 1, 2, or 3.# # version = 2## ## SNMP community string.# # community = "public"## ## Number of retries to attempt.# # retries = 3## ## The GETBULK max-repetitions parameter.# # max_repetitions = 10## ## SNMPv3 authentication and encryption options.# ### ## Security Name.# # sec_name = "myuser"# ## Authentication protocol; one of "MD5", "SHA", or "".# # auth_protocol = "MD5"# ## Authentication password.# # auth_password = "pass"# ## Security Level; one of "noAuthNoPriv", "authNoPriv", or "authPriv".# # sec_level = "authNoPriv"# ## Context Name.# # context_name = ""# ## Privacy protocol used for encrypted messages; one of "DES", "AES" or "".# # priv_protocol = ""# ## Privacy password used for encrypted messages.# # priv_password = ""## ## The maximum number of SNMP requests to make at the same time.# # max_parallel_lookups = 16## ## The amount of agents to cache entries for. If limit is reached,# ## oldest will be removed first. 0 means no limit.# # max_cache_entries = 100## ## Control whether the metrics need to stay in the same order this plugin# ## received them in. If false, this plugin may change the order when data is# ## cached. If you need metrics to stay in order set this to true. Keeping the# ## metrics ordered may be slightly slower.# # ordered = false## ## The amount of time entries are cached for a given agent. After this period# ## elapses if tags are needed they will be retrieved again.# # cache_ttl = "8h"## ## Minimum time between requests to an agent in case an index could not be# ## resolved. If set to zero no request on missing indices will be triggered.# # min_time_between_updates = "5m"## ## List of tags to be looked up.# [[processors.snmp_lookup.tag]]# ## Object identifier of the variable as a numeric or textual OID.# oid = "IF-MIB::ifName"## ## Name of the tag to create. If not specified, it defaults to the value of 'oid'.# ## If 'oid' is numeric, an attempt to translate the numeric OID into a textual OID# ## will be made.# # name = ""## ## Apply one of the following conversions to the variable value:# ## hwaddr: Convert the value to a MAC address.# ## ipaddr: Convert the value to an IP address.# ## enum(1): Convert the value according to its syntax in the MIB (full).# ## enum: Convert the value according to its syntax in the MIB.# ### # conversion = ""
# # Split a metric into one or more metrics with the specified field(s)/tag(s)# [[processors.split]]# ## Keeps the original metric by default# # drop_original = false## ## Template for an output metric# ## Users can define multiple templates to split the original metric into# ## multiple, potentially overlapping, metrics.# [[processors.split.template]]# ## New metric name# name = ""## ## List of tag keys for this metric template, accepts globs, e.g. "*"# tags = []## ## List of field keys for this metric template, accepts globs, e.g. "*"# fields = []
# # Process metrics using a Starlark script# [[processors.starlark]]# ## The Starlark source can be set as a string in this configuration file, or# ## by referencing a file containing the script. Only one source or script# ## should be set at once.## ## Source of the Starlark script.# source = '''# def apply(metric):# return metric# '''## ## File containing a Starlark script.# # script = "/usr/local/bin/myscript.star"## ## The constants of the Starlark script.# # [processors.starlark.constants]# # max_size = 10# # threshold = 0.75# # default_name = "Julia"# # debug_mode = true
# # Perform string processing on tags, fields, and measurements# [[processors.strings]]# ## Convert a field value to lowercase and store in a new field# # [[processors.strings.lowercase]]# # field = "uri_stem"# # dest = "uri_stem_normalised"## ## Convert a tag value to uppercase# # [[processors.strings.uppercase]]# # tag = "method"## ## Convert a field value to titlecase# # [[processors.strings.titlecase]]# # field = "status"## ## Trim leading and trailing whitespace using the default cutset# # [[processors.strings.trim]]# # field = "message"## ## Trim leading characters in cutset# # [[processors.strings.trim_left]]# # field = "message"# # cutset = "\t"## ## Trim trailing characters in cutset# # [[processors.strings.trim_right]]# # field = "message"# # cutset = "\r\n"## ## Trim the given prefix from the field# # [[processors.strings.trim_prefix]]# # field = "my_value"# # prefix = "my_"## ## Trim the given suffix from the field# # [[processors.strings.trim_suffix]]# # field = "read_count"# # suffix = "_count"## ## Replace all non-overlapping instances of old with new# # [[processors.strings.replace]]# # measurement = "*"# # old = ":"# # new = "_"## ## Trims strings based on width# # [[processors.strings.left]]# # field = "message"# # width = 10## ## Decode a base64 encoded utf-8 string# # [[processors.strings.base64decode]]# # field = "message"## ## Sanitize a string to ensure it is a valid utf-8 string# ## Each run of invalid UTF-8 byte sequences is replaced by the replacement string, which may be empty# # [[processors.strings.valid_utf8]]# # field = "message"# # replacement = ""
# # Restricts the number of tags that can pass through this filter and chooses which tags to preserve when over the limit.# [[processors.tag_limit]]# ## Maximum number of tags to preserve# limit = 3## ## List of tags to preferentially preserve# keep = ["environment", "region"]
# # Uses a Go template to create a new tag# [[processors.template]]# ## Go template used to create the tag name of the output. In order to# ## ease TOML escaping requirements, you should use single quotes around# ## the template string.# tag = "topic"## ## Go template used to create the tag value of the output. In order to# ## ease TOML escaping requirements, you should use single quotes around# ## the template string.# template = '{{ .Tag "hostname" }}.{{ .Tag "level" }}'
# # Convert a timestamp field to other timestamp format# [[processors.timestamp]]# ## Timestamp key to convert# ## Specify the field name that contains the timestamp to convert. The result# ## will replace the current field value.# field = ""## ## Timestamp Format# ## This defines the time layout used to interpret the source timestamp field.# ## The time must be `unix`, `unix_ms`, `unix_us`, `unix_ns`, or a time in Go# ## "reference time". For more information on Go "reference time". For more# ## see: https://golang.org/pkg/time/#Time.Format# source_timestamp_format = ""## ## Timestamp Timezone# ## Source timestamp timezone. If not set, assumed to be in UTC.# ## Options are as follows:# ## 1. UTC -- or unspecified will return timestamp in UTC# ## 2. Local -- interpret based on machine localtime# ## 3. "America/New_York" -- Unix TZ values like those found in# ## https://en.wikipedia.org/wiki/List_of_tz_database_time_zones# # source_timestamp_timezone = ""## ## Target timestamp format# ## This defines the destination timestamp format. It also can accept either# ## `unix`, `unix_ms`, `unix_us`, `unix_ns`, or a time in Go "reference time".# destination_timestamp_format = ""## ## Target Timestamp Timezone# ## Source timestamp timezone. If not set, assumed to be in UTC.# ## Options are as follows:# ## 1. UTC -- or unspecified will return timestamp in UTC# ## 2. Local -- interpret based on machine localtime# ## 3. "America/New_York" -- Unix TZ values like those found in# ## https://en.wikipedia.org/wiki/List_of_tz_database_time_zones# # destination_timestamp_timezone = ""
# # Print all metrics that pass through this filter.# [[processors.topk]]# ## How many seconds between aggregations# # period = 10## ## How many top buckets to return per field# ## Every field specified to aggregate over will return k number of results.# ## For example, 1 field with k of 10 will return 10 buckets. While 2 fields# ## with k of 3 will return 6 buckets.# # k = 10## ## Over which tags should the aggregation be done. Globs can be specified, in# ## which case any tag matching the glob will aggregated over. If set to an# ## empty list is no aggregation over tags is done# # group_by = ['*']## ## The field(s) to aggregate# ## Each field defined is used to create an independent aggregation. Each# ## aggregation will return k buckets. If a metric does not have a defined# ## field the metric will be dropped from the aggregation. Considering using# ## the defaults processor plugin to ensure fields are set if required.# # fields = ["value"]## ## What aggregation function to use. Options: sum, mean, min, max# # aggregation = "mean"## ## Instead of the top k largest metrics, return the bottom k lowest metrics# # bottomk = false## ## The plugin assigns each metric a GroupBy tag generated from its name and# ## tags. If this setting is different than "" the plugin will add a# ## tag (which name will be the value of this setting) to each metric with# ## the value of the calculated GroupBy tag. Useful for debugging# # add_groupby_tag = ""## ## These settings provide a way to know the position of each metric in# ## the top k. The 'add_rank_field' setting allows to specify for which# ## fields the position is required. If the list is non empty, then a field# ## will be added to each and every metric for each string present in this# ## setting. This field will contain the ranking of the group that# ## the metric belonged to when aggregated over that field.# ## The name of the field will be set to the name of the aggregation field,# ## suffixed with the string '_topk_rank'# # add_rank_fields = []## ## These settings provide a way to know what values the plugin is generating# ## when aggregating metrics. The 'add_aggregate_field' setting allows to# ## specify for which fields the final aggregation value is required. If the# ## list is non empty, then a field will be added to each every metric for# ## each field present in this setting. This field will contain# ## the computed aggregation for the group that the metric belonged to when# ## aggregated over that field.# ## The name of the field will be set to the name of the aggregation field,# ## suffixed with the string '_topk_aggregate'# # add_aggregate_fields = []
# # Rotate multi field metric into several single field metrics# [[processors.unpivot]]# ## Metric mode to pivot to# ## Set to "tag", metrics are pivoted as a tag and the metric is kept as# ## the original measurement name. Tag key name is set by tag_key value.# ## Set to "metric" creates a new metric named the field name. With this# ## option the tag_key is ignored. Be aware that this could lead to metric# ## name conflicts!# # use_fieldname_as = "tag"## ## Tag to use for the name.# # tag_key = "name"## ## Field to use for the name of the value.# # value_key = "value"
################################################################################ AGGREGATOR PLUGINS ################################################################################
# # Keep the aggregate basicstats of each metric passing through.# [[aggregators.basicstats]]# ## The period on which to flush & clear the aggregator.# period = "30s"## ## If true, the original metric will be dropped by the# ## aggregator and will not get sent to the output plugins.# drop_original = false## ## Configures which basic stats to push as fields# # stats = ["count","diff","rate","min","max","mean","non_negative_diff","non_negative_rate","percent_change","stdev","s2","sum","interval","last"]
# # Calculates a derivative for every field.# [[aggregators.derivative]]# ## The period in which to flush the aggregator.# period = "30s"# ### ## Suffix to append for the resulting derivative field.# # suffix = "_rate"# ### ## Field to use for the quotient when computing the derivative.# ## When using a field as the derivation parameter the name of that field will# ## be used for the resulting derivative, e.g. *fieldname_by_parameter*.# ## By default the timestamps of the metrics are used and the suffix is omitted.# # variable = ""# ### ## Maximum number of roll-overs in case only one measurement is found during a period.# # max_roll_over = 10
# # Report the final metric of a series# [[aggregators.final]]# ## The period on which to flush & clear the aggregator.# period = "30s"## ## If true, the original metric will be dropped by the# ## aggregator and will not get sent to the output plugins.# # drop_original = false## ## If false, _final is added to every field name# # keep_original_field_names = false## ## The time that a series is not updated until considering it final. Ignored# ## when output_strategy is "periodic".# # series_timeout = "5m"## ## Output strategy, supported values:# ## timeout -- output a metric if no new input arrived for `series_timeout`# ## periodic -- output the last received metric every `period`# # output_strategy = "timeout"
# # Configuration for aggregate histogram metrics# [[aggregators.histogram]]# ## The period in which to flush the aggregator.# period = "30s"## ## If true, the original metric will be dropped by the# ## aggregator and will not get sent to the output plugins.# drop_original = false## ## If true, the histogram will be reset on flush instead# ## of accumulating the results.# reset = false## ## Whether bucket values should be accumulated. If set to false, "gt" tag will be added.# ## Defaults to true.# cumulative = true## ## Expiration interval for each histogram. The histogram will be expired if# ## there are no changes in any buckets for this time interval. 0 == no expiration.# # expiration_interval = "0m"## ## If true, aggregated histogram are pushed to output only if it was updated since# ## previous push. Defaults to false.# # push_only_on_update = false## ## Example config that aggregates all fields of the metric.# # [[aggregators.histogram.config]]# # ## Right borders of buckets (with +Inf implicitly added).# # buckets = [0.0, 15.6, 34.5, 49.1, 71.5, 80.5, 94.5, 100.0]# # ## The name of metric.# # measurement_name = "cpu"## ## Example config that aggregates only specific fields of the metric.# # [[aggregators.histogram.config]]# # ## Right borders of buckets (with +Inf implicitly added).# # buckets = [0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0]# # ## The name of metric.# # measurement_name = "diskio"# # ## The concrete fields of metric# # fields = ["io_time", "read_time", "write_time"]
# # Merge metrics into multifield metrics by series key# [[aggregators.merge]]# ## Precision to round the metric timestamp to# ## This is useful for cases where metrics to merge arrive within a small# ## interval and thus vary in timestamp. The timestamp of the resulting metric# ## is also rounded.# # round_timestamp_to = "1ns"## ## If true, the original metric will be dropped by the# ## aggregator and will not get sent to the output plugins.# drop_original = true
# # Keep the aggregate min/max of each metric passing through.# [[aggregators.minmax]]# ## General Aggregator Arguments:# ## The period on which to flush & clear the aggregator.# period = "30s"# ## If true, the original metric will be dropped by the# ## aggregator and will not get sent to the output plugins.# drop_original = false
# # Keep the aggregate quantiles of each metric passing through.# [[aggregators.quantile]]# ## General Aggregator Arguments:# ## The period on which to flush & clear the aggregator.# period = "30s"## ## If true, the original metric will be dropped by the# ## aggregator and will not get sent to the output plugins.# drop_original = false## ## Quantiles to output in the range [0,1]# # quantiles = [0.25, 0.5, 0.75]## ## Type of aggregation algorithm# ## Supported are:# ## "t-digest" -- approximation using centroids, can cope with large number of samples# ## "exact R7" -- exact computation also used by Excel or NumPy (Hyndman & Fan 1996 R7)# ## "exact R8" -- exact computation (Hyndman & Fan 1996 R8)# ## NOTE: Do not use "exact" algorithms with large number of samples# ## to not impair performance or memory consumption!# # algorithm = "t-digest"## ## Compression for approximation (t-digest). The value needs to be# ## greater or equal to 1.0. Smaller values will result in more# ## performance but less accuracy.# # compression = 100.0
# # Aggregate metrics using a Starlark script# [[aggregators.starlark]]# ## The Starlark source can be set as a string in this configuration file, or# ## by referencing a file containing the script. Only one source or script# ## should be set at once.# ### ## Source of the Starlark script.# source = '''# state = {}## def add(metric):# state["last"] = metric## def push():# return state.get("last")## def reset():# state.clear()# '''## ## File containing a Starlark script.# # script = "/usr/local/bin/myscript.star"## ## The constants of the Starlark script.# # [aggregators.starlark.constants]# # max_size = 10# # threshold = 0.75# # default_name = "Julia"# # debug_mode = true
# # Count the occurrence of values in fields.# [[aggregators.valuecounter]]# ## General Aggregator Arguments:# ## The period on which to flush & clear the aggregator.# period = "30s"# ## If true, the original metric will be dropped by the# ## aggregator and will not get sent to the output plugins.# drop_original = false# ## The fields for which the values will be counted# fields = ["status"]
################################################################################ SERVICE INPUT PLUGINS ################################################################################
# Read metrics from MQTT topic(s)[[inputs.mqtt_consumer]] ## Broker URLs for the MQTT server or cluster. To connect to multiple ## clusters or standalone servers, use a separate plugin instance. ## example: servers = ["tcp://localhost:1883"] ## servers = ["ssl://localhost:1883"] ## servers = ["ws://localhost:1883"] servers = ["tcp://127.0.0.1:1883"]
## Topics that will be subscribed to. topics = [ "telegraf/host01/cpu", "telegraf/+/mem", "sensors/#", ]
## The message topic will be stored in a tag specified by this value. If set ## to the empty string no topic tag will be created. # topic_tag = "topic"
## QoS policy for messages ## 0 = at most once ## 1 = at least once ## 2 = exactly once ## ## When using a QoS of 1 or 2, you should enable persistent_session to allow ## resuming unacknowledged messages. # qos = 0
## Connection timeout for initial connection in seconds # connection_timeout = "30s"
## Interval and ping timeout for keep-alive messages ## The sum of those options defines when a connection loss is detected. ## Note: The keep-alive interval needs to be greater or equal one second and ## fractions of a second are not supported. # keepalive = "60s" # ping_timeout = "10s"
## Max undelivered messages ## This plugin uses tracking metrics, which ensure messages are read to ## outputs before acknowledging them to the original broker to ensure data ## is not lost. This option sets the maximum messages to read from the ## broker that have not been written by an output. ## ## This value needs to be picked with awareness of the agent's ## metric_batch_size value as well. Setting max undelivered messages too high ## can result in a constant stream of data batches to the output. While ## setting it too low may never flush the broker's messages. # max_undelivered_messages = 1000
## Persistent session disables clearing of the client session on connection. ## In order for this option to work you must also set client_id to identify ## the client. To receive messages that arrived while the client is offline, ## also set the qos option to 1 or 2 and don't forget to also set the QoS when ## publishing. Finally, using a persistent session will use the initial ## connection topics and not subscribe to any new topics even after ## reconnecting or restarting without a change in client ID. # persistent_session = false
## If unset, a random client ID will be generated. # client_id = ""
## Username and password to connect MQTT server. # username = "telegraf" # password = "metricsmetricsmetricsmetrics"
## Optional TLS Config # tls_ca = "/etc/telegraf/ca.pem" # tls_cert = "/etc/telegraf/cert.pem" # tls_key = "/etc/telegraf/key.pem" ## Use TLS but skip chain & host verification # insecure_skip_verify = false
## Client trace messages ## When set to true, and debug mode enabled in the agent settings, the MQTT ## client's messages are included in telegraf logs. These messages are very ## noisey, but essential for debugging issues. # client_trace = false
## Data format to consume. ## Each data format has its own unique set of configuration options, read ## more about them here: ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md data_format = "influx"
## Enable extracting tag values from MQTT topics ## _ denotes an ignored entry in the topic path, ## # denotes a variable length path element (can only be used once per setting) # [[inputs.mqtt_consumer.topic_parsing]] # topic = "" # measurement = "" # tags = "" # fields = "" ## Value supported is int, float, unit # [inputs.mqtt_consumer.topic_parsing.types] # key = type
README.md+3
app.pyDeleted-90
dash/README.mdAdded+3
dash/app.pyAdded+153
gradio/README.mdAdded
gradio/app.pyAdded+114
node-red/README.mdAdded
node-red/influxdb_line_protocol_conversion.jsAdded
notebooks/tests.ipynbAdded+274
streamlit/app.pyAdded+51
telegraf/README.mdAdded
telegraf/telegraf.confAdded+1687