{
"label1": "value1",
"label2": "value2",
"service": ["svc1", "svc2"]
}
service 有多少个元素,建返回多位条数据
{
"description": "",
"metric_name": "",
"labels": {"k1":"v1", "k2":"v2"},
"value_type": "Counter|Gauge",
"value": 123456
}
- 脚本名称必须以"exporter_"开头
- 脚本支持bash和python, 必须按照脚本规范,第一行注释脚本解释器
- metric_name 不能重复
python 脚本
#!/bin/python
print('''{
"description": "this is test metris",
"metric_name": "node_this_random_py",
"value_type": "counter",
"labels": {"k1":"v1", "k2":"v2"},
"value": 1.2345
}''')
bash 脚本
#! /bin/bash
echo '
{
"description": "this is test metris",
"metric_name": "node_this_random",
"value_type": "counter",
"labels": {"k1":"v1", "k2":"v2"},
"value": 1.2345
}
'
package main
import (
"github.com/kylin-ops/node-exporter"
"net/http"
)
func main() {
var (
listenAddress = ":9100"
metricsPath = "/metrics"
)
labelsPath := "/tmp/labels"
scriptPath := "/tmp/scripts"
handler := node_exporter.NewNodeExportHandler(labelsPath, scriptPath)
http.Handle(metricsPath, handler)
http.ListenAndServe(listenAddress, nil)
}