Report custom metrics to Nightingale from scripts (Exec)
For anything no plugin covers: write a script that prints Prometheus, InfluxDB line protocol or Open-Falcon format to stdout, and Categraf collects and ships it.
Last reviewed
The exec input is Categraf's catch-all. You write a script, the script prints metrics to standard output, and Categraf runs it on a schedule and parses the result. Any language works; the output must be one of three formats, chosen with data_format: Prometheus text exposition, InfluxDB line protocol (measurement,label=v field=1) or Open-Falcon JSON.
Use it for business metrics, health checks of legacy systems and one-off inspection scripts. Keep the script's run time below the collection interval, and remember that values must be numeric.
What's in the template
- Categraf collector config:
input.exec
How to connect
-
Install Categraf, put the config below in
conf/input.exec/exec.toml, fill in your own address and credentials, and restart Categraf. The startup log printsinput: local.exec startedonce the plugin is loaded.# # collect interval# interval = 15[[instances]]# # commands, support globcommands = [# "/opt/categraf/scripts/*.sh"]# # timeout for each command to complete# timeout = 5# # interval = global.interval * interval_times# interval_times = 1# # choices: influx prometheus falcon# # influx stdout example: measurement,labelkey1=labelval1,labelkey2=labelval2 field1=1.2,field2=2.3# data_format = "influx"
Related
- Exec template source: the raw JSON for dashboards, rules and collector config. Pull requests welcome.
- Categraf
execplugin docs: every config option and the full metric list. - Walkthrough: custom metrics from scripts
- Import dashboards and alert rules
- Verify that metrics are stored
- All integrations