diff --git a/README.md b/README.md index 333fd27..d0376f8 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ Main limitation - one instance = one query. | ZE3000_METRIC_VALUE | `Mapping field.` Which field form Zabbix response use as value of metric. `Only top level Zabbix response fields supported`| lastvalue | | ZE3000_METRIC_HELP | `Mapping field.` Which field form Zabbix response use as help field of metric. `Only top level Zabbix response fields supported` | description | | ZE3000_ZABBIX_METRIC_LABELS | `Mapping field.` Which field form Zabbix response use as labels. `This field supported first level and second level fields ` | name,
itemid,
key_,
hosts>host,
hosts>name,
interfaces>ip,
interface>dns | +| ZE3000_METRIC_URI_PATH | uri path where prometheus can consume metrics | /metrics | | ZE3000_ZABBIX_REFRESH_DELAY_SEC | How frequent Zabbix exporter will be query Zabbix. In seconds | 10 | | ZE3000_ZABBIX_QUERY | any Zabbix query, with field "auth" with value "%auth-token%" - yes, literally `"%auth-token%"` |{"jsonrpc": "2.0",
"method": "item.get",
"params": {
"application":"My Valuable Application",
"output":["itemid","key_","description","lastvalue"],
"selectDependencies": "extend",
"selectHosts": ["name","status","host"],
"selectInterfaces": ["ip","dns"],
"sortfield":"key_" },
"auth": "%auth-token%",
"id": 1 } | @@ -122,6 +123,7 @@ docker run -d \ -e ZE3000_METRIC_NAME_FIELD="key_" \ -e ZE3000_METRIC_VALUE="lastvalue" \ -e ZE3000_METRIC_HELP="description" \ + -e ZE3000_METRIC_URI_PATH="/my-metrics" -e ZE3000_ZABBIX_REFRESH_DELAY_SEC=20 \ -e ZE3000_ZABBIX_METRIC_LABELS="itemid,key_,hosts>host,hosts>name,interfaces>ip,interface>dns" \ -e ZE3000_HOST_PORT=localhost:8080 \ @@ -130,14 +132,14 @@ docker run -d \ ``` :boom: let's suppose everything running ok, and you don't have any error messages from ze3000

-ze3000 brings up next endpoints: -- `/metrics` - main and exported metrics +by default ze3000 brings up next endpoints: +- `/metrics` - main and exported metrics (you can change it over ZE3000_METRIC_URI_PATH environment variable. In exampe above this env variable set to `/my-metrics`) - `/ready` - readiness probe for k8s monitoring - `/live` - liveness probe for k8s monitoring -Let's se at `/metrics` +Let's se at `/my-metrics` ``` bash -$ curl http://localhost:8080/metrics +$ curl http://localhost:8080/my-metrics ... megacompany_frontend_nginx_concurrencyconnections{hosts_host="mighty.fronend",hosts_name="Mighty Frontend",interface_dns="NA",interfaces_ip="10.4.4.3",itemid="452345",key_="concurrencyConnections"} 9 ... diff --git a/config/config.go b/config/config.go index bd66763..7b86744 100644 --- a/config/config.go +++ b/config/config.go @@ -25,6 +25,7 @@ var ( MetricNameField = getEnv("ZE3000_METRIC_NAME_FIELD", "key_") MetricValue = getEnv("ZE3000_METRIC_VALUE", "lastvalue") MetricHelpField = getEnv("ZE3000_METRIC_HELP", "description") + MetricUriPath = getEnv("ZE3000_METRIC_URI_PATH", "/metrics") SourceRefresh = getEnv("ZE3000_ZABBIX_REFRESH_DELAY_SEC", "10") MetricLabels = strings.TrimSpace(getEnv("ZE3000_ZABBIX_METRIC_LABELS", "name,itemid,key_,hosts>host,hosts>name,interfaces>ip,interface>dns")) Query = getEnv("ZE3000_ZABBIX_QUERY", `{ "jsonrpc": "2.0", "method": "item.get", "params": { "application":"My Super Application", "output": ["itemid","key_","description","lastvalue"], "selectDependencies": "extend", "selectHosts": ["name","status","host"], "selectInterfaces": ["ip","dns"], "sortfield":"key_" }, "auth": "%auth-token%", "id": 1 }`) diff --git a/k8s/Deployment.yaml b/k8s/Deployment.yaml index bfa5db8..0f1c6c7 100644 --- a/k8s/Deployment.yaml +++ b/k8s/Deployment.yaml @@ -49,6 +49,8 @@ spec: value: "key_" - name: ZE3000_METRIC_VALUE value: "lastvalue" + - name: ZE3000_METRIC_URI_PATH + value: "/metrics" - name: ZE3000_METRIC_HELP value: "description" - name: ZE3000_ZABBIX_REFRESH_DELAY_SEC diff --git a/main.go b/main.go index fcea182..bac314a 100644 --- a/main.go +++ b/main.go @@ -34,7 +34,7 @@ func main() { m := prometheusMiddleware.New("ze3000", 0.3, 1.2, 5.0) hdl.RecordMetrics() app.Use(m.ServeHTTP) - app.Get("/metrics", iris.FromStd(promhttp.Handler())) + app.Get(cnf.MetricUriPath, iris.FromStd(promhttp.Handler())) app.Get("/liveness", func(ctx iris.Context) { ctx.WriteString("ok")