prometheus/pkg/textparse
Julien Pivotto ed623f69e2
tsdb: don't allow ingesting empty labelsets (#6891)
* tsdb: don't allow ingesting empty labelsets

When we ingest an empty labelset in the head, further blocks can not be
compacted, with the error:

```
level=error ts=2020-02-27T21:26:58.379Z caller=db.go:659 component=tsdb
msg="compaction failed" err="persist head block: write compaction:
add series: out-of-order series added with label set \"{}\" / prev:
\"{}\""
```

We should therefore reject those invalid empty labelsets upfront.

This can be reproduced with the following:

```
cat << END > prometheus.yml
scrape_configs:
  - job_name: 'prometheus'
    scrape_interval: 1s
    basic_auth:
      username: test
      password: test
    metric_relabel_configs:
    - regex: ".*"
      action: labeldrop

    static_configs:
    - targets:
      - 127.0.1.1:9090
END
./prometheus --storage.tsdb.min-block-duration=1m
```
And wait a few minutes.

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2020-03-02 07:18:05 +00:00
..
interface.go Add exemplar support to the openmetrics parser (#6292) 2019-11-19 09:33:30 +00:00
openmetricslex.l Add exemplar support to the openmetrics parser (#6292) 2019-11-19 09:33:30 +00:00
openmetricslex.l.go Add exemplar support to the openmetrics parser (#6292) 2019-11-19 09:33:30 +00:00
openmetricsparse.go OpenMetrics parse: avoid setting prev token (#6781) 2020-02-07 07:33:26 +00:00
openmetricsparse_test.go tsdb: don't allow ingesting empty labelsets (#6891) 2020-03-02 07:18:05 +00:00
promlex.l Prepare for multiple text formats 2018-10-18 13:58:00 +01:00
promlex.l.go Add exemplar support to the openmetrics parser (#6292) 2019-11-19 09:33:30 +00:00
promparse.go Add exemplar support to the openmetrics parser (#6292) 2019-11-19 09:33:30 +00:00
promparse_test.go tsdb: don't allow ingesting empty labelsets (#6891) 2020-03-02 07:18:05 +00:00
promtestdata.nometa.txt Add an OpenMetrics parser. 2018-10-18 13:58:00 +01:00
promtestdata.txt Add an OpenMetrics parser. 2018-10-18 13:58:00 +01:00
README.md Add a README.md to textparse package about how to update lexers. 2019-10-23 23:55:42 -07:00

Making changes to textparse lexers

In the rare case that you need to update the textparse lexers, edit promlex.l or openmetricslex.l and then run the following command: golex -o=promlex.l.go promlex.l

Note that you need golex installed: go get -u modernc.org/golex