This tool helps to automatically generate the spec file and docs for integrations.
In input folder you need to place the prometheus output of the exporter together with the entity synthesis rules.
The tool is not fully parametrised yet, therefore if you need to change any parameter you can check directly the main.go.
Run it with go run ./cmd/docs-specs-generator/main.go --prom_metrics_path=etcd.prom
. The output is placed in the output folder.
-
You still need to indicate for each metric the unit in the spec file with one of
count, percent, seconds, milliseconds, microsenconds, bytes, countPerSecond, bytesPerSecond, bitPerSecond
-
You still need to add the description of the integration in the docs, it only helps to generate the metrics list with the description.
-
You still need to review is the output makes sense and is compliant with all specifications.
The tool aims to detect from a prometheus output the wrong metrics and provides the rules in order to fix them. To detect the broken metrics, i.e. not following
metricName_bucket is stored as a New Relic count metric type.
metricName_count is stored as a New Relic count metric type.
metricName_total is stored as a New Relic count metric type.
we run a query similar to:
FROM Metric SELECT uniqueCount(metricName) where
(nrMetricType='gauge' and (metricName LIKE '%_total' or metricName LIKE '%_count' )) or
(nrMetricType='count' and (metricName NOT LIKE '%_total' and metricName NOT LIKE '%_count' ))
and collector.name = 'nri-prometheus' limit max
Currently, the tool focus on counter only since the summary one should not break since they are autogenerated. However, we can add that if we notice that it is useful:
metricName_sum is stored as a New Relic summary metric type.
go run ./cmd/wrong-type-detector/main.go -h
Usage of main:
-outputMetrics string
output for the broken metrics (default "output/broken.yaml")
-outputRules string
output for the rules to fix broken metrics (default "output/rules.yaml")
-promInput string
source for the prometheus metrics (default "./powerdns.prom")
Simply run:
$ go run ./cmd/wrong-type-detector/main.go
2022/10/12 16:53:46 broken metrics detected in "./powerdns.prom", placed in "output/broken.yaml" and the rules fixen them in "output/rules.yaml"