Filter out testfile metrics correctly when using collect[] filters (#763)

* remove injection hook for textfile metrics, convert them to prometheus format

* add support for summaries

* add support for histograms

* add logic for handling inconsistent labels within a metric family for counter, gauge, untyped

* change logic for parsing the metrics textfile

* fix logic to adding missing labels

* Export time and error metrics for textfiles

* Add tests for new textfile collector, fix found bugs

* refactor Update() to split into smaller functions

* remove parseTextFiles(), fix import issue

* add mtime metric directly to channel, fix handling of mtime during testing

* rename variables related to labels

* refactor: add default case, remove if guard for metrics, remove extra loop and slice

* refactor: remove extra loop iterating over metric families

* test: add test case for different metric type, fix found bug

* test: add test for metrics with inconsistent labels

* test: add test for histogram

* test: add test for histogram with extra dimension

* test: add test for summary

* test: add test for summary with extra dimension

* remove unnecessary creation of protobuf

* nit: remove extra blank line
This commit is contained in:
Shubheksha Jalan 2017-12-24 00:51:58 +05:30 committed by Julius Volz
commit 1f2458f42c
17 changed files with 513 additions and 175 deletions

View file

@ -1,79 +1,19 @@
name: "node_textfile_mtime"
help: "Unixtime mtime of textfiles successfully read."
type: GAUGE
metric: <
label: <
name: "file"
value: "metrics1.prom"
>
gauge: <
value: 1
>
>
metric: <
label: <
name: "file"
value: "metrics2.prom"
>
gauge: <
value: 2
>
>
name: "node_textfile_scrape_error"
help: "1 if there was an error opening or reading a file, 0 otherwise"
type: GAUGE
metric: <
gauge: <
value: 0
>
>
name: "testmetric1_1"
help: "Metric read from fixtures/textfile/two_metric_files/metrics1.prom"
type: UNTYPED
metric: <
label: <
name: "foo"
value: "bar"
>
untyped: <
value: 10
>
>
name: "testmetric1_2"
help: "Metric read from fixtures/textfile/two_metric_files/metrics1.prom"
type: UNTYPED
metric: <
label: <
name: "foo"
value: "baz"
>
untyped: <
value: 20
>
>
name: "testmetric2_1"
help: "Metric read from fixtures/textfile/two_metric_files/metrics2.prom"
type: UNTYPED
metric: <
label: <
name: "foo"
value: "bar"
>
untyped: <
value: 30
>
timestamp_ms: 1441205977284
>
name: "testmetric2_2"
help: "Metric read from fixtures/textfile/two_metric_files/metrics2.prom"
type: UNTYPED
metric: <
label: <
name: "foo"
value: "baz"
>
untyped: <
value: 40
>
timestamp_ms: 1441205977284
>
# HELP node_textfile_mtime Unixtime mtime of textfiles successfully read.
# TYPE node_textfile_mtime gauge
node_textfile_mtime{file="metrics1.prom"} 1
node_textfile_mtime{file="metrics2.prom"} 1
# HELP node_textfile_scrape_error 1 if there was an error opening or reading a file, 0 otherwise
# TYPE node_textfile_scrape_error gauge
node_textfile_scrape_error 0
# HELP testmetric1_1 Metric read from fixtures/textfile/two_metric_files/metrics1.prom
# TYPE testmetric1_1 untyped
testmetric1_1{foo="bar"} 10
# HELP testmetric1_2 Metric read from fixtures/textfile/two_metric_files/metrics1.prom
# TYPE testmetric1_2 untyped
testmetric1_2{foo="baz"} 20
# HELP testmetric2_1 Metric read from fixtures/textfile/two_metric_files/metrics2.prom
# TYPE testmetric2_1 untyped
testmetric2_1{foo="bar"} 30
# HELP testmetric2_2 Metric read from fixtures/textfile/two_metric_files/metrics2.prom
# TYPE testmetric2_2 untyped
testmetric2_2{foo="baz"} 40