Manik Rana
315165e49d
refac: make typeRequiresCT private
...
Signed-off-by: Manik Rana <manikrana54@gmail.com>
2 months ago
Nathan Baulch
50cd453c8f
chore: Fix typos ( #14868 )
...
* Fix typos
---------
Signed-off-by: Nathan Baulch <nathan.baulch@gmail.com>
2 months ago
Manik Rana
02c465bf58
textparse: Implement `CreatedTimestamp()` in `openmetricsparse.go` ( #14356 )
...
* feat: initial implement of createedTimestamp() with tests
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* feat: return ct after finding it
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* chore: remove unneeded test
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* chore: add comments
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* feat: multiple changes
- implement changes from pair programming session
- use newParse.val()
- advance parser p if ct is found
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* fix: check if err from p.Next()
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* feat: advance parser and parse histograms + summary
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* fix: restore previous tests
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* fix: retore failing tests
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* chore: remove unneeded comments
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* fix: return nil when mtype doesn't match
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* chore: update go fmt version
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* chore: cleanup
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* fix: comments
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* feat: document deepcopyparser
Co-authored-by: Arthur Silva Sens <arthursens2005@gmail.com>
Signed-off-by: Manik Rana <Manikrana54@gmail.com>
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* chore: lint
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* fix: cover edgecase of `gauge_created` in CreatedTimestamp()
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* refac: readability updates
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* refac: dedeuplicate labeldiff checks
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* tests: add tests for new label functions
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* feat: document CreatedTimestamp func
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* refac: optimize `CreatedTimestamp()`
- Use refactored CreatedTimestamp function with bug fixes
- Remove unused code in labels.go
- Improve code documentation
Signed-off-by: Manik Rana <manikrana54@gmail.com>
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* chore: add tests and lint fixes
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* chore: remove mName
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* chore: lint
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* chore: comments
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* tests: add tests for CT parse failures and deepCopy
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* refac: edit expectCT struct
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* chore: lint
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* chore: add new label in deepCopy
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* fix: use p.builder in deepCopy
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* fix: add NewMetricsParserWithOpts
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* chore: lint
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* chore: comments
Co-authored-by: Arthur Silva Sens <arthursens2005@gmail.com>
Signed-off-by: Manik Rana <Manikrana54@gmail.com>
* chore: comments
Co-authored-by: Arthur Silva Sens <arthursens2005@gmail.com>
Signed-off-by: Manik Rana <Manikrana54@gmail.com>
* chore: rename var
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* fix: add condition for OM fuzzing
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* fix: build tags
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* refac: default skipCT to false
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* refac: rename skipCT to skipCTSeries
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* chore: formatting
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* chore: comments and readability updates
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* chore: comments
Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com>
Signed-off-by: Manik Rana <Manikrana54@gmail.com>
* refac: remove NewOpenMetricsParserWithOpts
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* chore: lint
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* refac: extract skipCTSeries logic from parseMetricSuffix
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* refac: inline create a NewOpenMetricsParser
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* chore: comments
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* chore: comments
Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com>
Signed-off-by: Manik Rana <Manikrana54@gmail.com>
* refac: improve error handling
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* fix: return error instead of nil
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* fix: remove skipCT check from tBraceOpen
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* Pair programming with Manik, Arthur and Daniel.
Signed-off-by: bwplotka <bwplotka@gmail.com>
* chore: comments and use helper funcs
Signed-off-by: Manik Rana <manikrana54@gmail.com>
* chore: lint
Signed-off-by: Manik Rana <manikrana54@gmail.com>
---------
Signed-off-by: Manik Rana <manikrana54@gmail.com>
Signed-off-by: Manik Rana <Manikrana54@gmail.com>
Signed-off-by: bwplotka <bwplotka@gmail.com>
Co-authored-by: Arthur Silva Sens <arthursens2005@gmail.com>
Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com>
4 months ago
Arthur Silva Sens
07355c9199
Bump client_golang to 1.19
...
Signed-off-by: Arthur Silva Sens <arthur.sens@coralogix.com>
9 months ago
Bryan Boreham
ba6aa95222
refactor: metrics parsing: extract common checking code
...
Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
9 months ago
Bryan Boreham
eff3a13e19
model/textparse: parsers take a labels SymbolTable
...
This allows strings to be interned to save memory.
Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
9 months ago
Bryan Boreham
93b72ec5dd
tsdb: create SymbolTables for labels as required
...
Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
9 months ago
Łukasz Mierzwa
5597020a60
Use github.com/klauspost/compress for gzip and zlib
...
klauspost/compress is a high quality drop-in replacement for common Go
compression libraries. Since Prometheus sends out a lot of HTTP requests
that often return compressed output having improved compression
libraries helps to save cpu & memory resources.
On a test Prometheus server I was able to see cpu reduction from 31 to
30 cores.
Benchmark results:
name old time/op new time/op delta
TargetScraperGzip/metrics=1-8 69.4µs ± 4% 69.2µs ± 3% ~ (p=0.122 n=50+50)
TargetScraperGzip/metrics=100-8 84.3µs ± 2% 80.9µs ± 2% -4.02% (p=0.000 n=48+46)
TargetScraperGzip/metrics=1000-8 296µs ± 1% 274µs ±14% -7.35% (p=0.000 n=47+45)
TargetScraperGzip/metrics=10000-8 2.06ms ± 1% 1.66ms ± 2% -19.34% (p=0.000 n=47+45)
TargetScraperGzip/metrics=100000-8 20.9ms ± 2% 17.5ms ± 3% -16.50% (p=0.000 n=49+50)
name old alloc/op new alloc/op delta
TargetScraperGzip/metrics=1-8 6.06kB ± 0% 6.07kB ± 0% +0.24% (p=0.000 n=48+48)
TargetScraperGzip/metrics=100-8 7.04kB ± 0% 6.89kB ± 0% -2.17% (p=0.000 n=49+50)
TargetScraperGzip/metrics=1000-8 9.02kB ± 0% 8.35kB ± 1% -7.49% (p=0.000 n=50+50)
TargetScraperGzip/metrics=10000-8 18.1kB ± 1% 16.1kB ± 2% -10.87% (p=0.000 n=47+47)
TargetScraperGzip/metrics=100000-8 1.21MB ± 0% 1.01MB ± 2% -16.69% (p=0.000 n=36+50)
name old allocs/op new allocs/op delta
TargetScraperGzip/metrics=1-8 71.0 ± 0% 72.0 ± 0% +1.41% (p=0.000 n=50+50)
TargetScraperGzip/metrics=100-8 81.0 ± 0% 76.0 ± 0% -6.17% (p=0.000 n=50+50)
TargetScraperGzip/metrics=1000-8 92.0 ± 0% 83.0 ± 0% -9.78% (p=0.000 n=50+50)
TargetScraperGzip/metrics=10000-8 93.0 ± 0% 91.0 ± 0% -2.15% (p=0.000 n=50+50)
TargetScraperGzip/metrics=100000-8 111 ± 0% 135 ± 1% +21.89% (p=0.000 n=40+50)
Signed-off-by: Łukasz Mierzwa <l.mierzwa@gmail.com>
9 months ago
Owen Williams
a28d7865ad
UTF-8: Add support for parsing UTF8 metric and label names
...
This adds support for the new grammar of `{"metric_name", "l1"="val"}` to promql and some of the exposition formats.
This grammar will also be valid for non-UTF-8 names.
UTF-8 names will not be considered valid unless model.NameValidationScheme is changed.
This does not update the go expfmt parser in text_parse.go, which will be addressed by https://github.com/prometheus/common/issues/554/ .
Part of https://github.com/prometheus/prometheus/issues/13095
Signed-off-by: Owen Williams <owen.williams@grafana.com>
9 months ago
Bryan Boreham
17f48f2b3b
Tests: use replacement DeepEquals in more places
...
Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
10 months ago
Bryan Boreham
8065bef172
Move metric type definitions to common/model
...
They are used in multiple repos, so common is a better place for them.
Several packages now don't depend on `model/textparse`, e.g.
`storage/remote`.
Also remove `metadata` struct from `api.go`, since it was identical to
a struct in the `metadata` package.
Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
11 months ago
Matthieu MOREL
9c4782f1cc
golangci-lint: enable testifylint linter ( #13254 )
...
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
12 months ago
Matthieu MOREL
fb3eb21230
enable gocritic, unconvert and unused linters
...
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2 years ago
Damien Grisonnet
e3b5416d05
model/textparse: improve error outputs
...
Parsing errors in the Prometheus HTTP format parser are very hard to
investigate since they only approximately indicate what is going wrong
in the parser and don't provide any information about the incorrect
input. As such it is very hard to tell what is wrong in the format
exposed by the application.
Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
2 years ago
Damien Grisonnet
96b9d8cebb
model/textparse: associate correct token to errors
...
In some cases, the Prometheus HTTP format parser was not returning the
right token in the error output which made debugging impossible.
Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
2 years ago
Bryan Boreham
8d350d9e0c
Update package model/textparse tests for new labels.Labels type
...
We don't want to touch the result labels now we create them differently.
Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
2 years ago
Bryan Boreham
8120af22e2
benchmarks: SetBytes takes bytes per operation
...
Where the code was multiplying bytes by number of operations, this
resulted in absurdly high throughput numbers.
Also, in `BenchmarkParse()`, don't run the `expfmt` case twice.
Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
2 years ago
Julien Pivotto
96d5a32659
Update go to 1.19, set min version to 1.18 ( #11279 )
...
* Update go to 1.19, set min version to 1.18
Signed-off-by: Julien Pivotto <roidelapluie@o11y.eu>
* Update golangci-lint
Signed-off-by: Julien Pivotto <roidelapluie@o11y.eu>
Signed-off-by: Julien Pivotto <roidelapluie@o11y.eu>
2 years ago
Matthieu MOREL
c2b4de3611
refactor (package model): move from github.com/pkg/errors to 'errors' and 'fmt' packages ( #10747 )
...
Signed-off-by: Matthieu MOREL <mmorel-35@users.noreply.github.com>
Co-Authored-By: Julien Pivotto <roidelapluie@gmail.com>
Co-authored-by: Julien Pivotto <roidelapluie@gmail.com>
2 years ago
Matthieu MOREL
e2ede285a2
refactor: move from io/ioutil to io and os packages ( #10528 )
...
* refactor: move from io/ioutil to io and os packages
* use fs.DirEntry instead of os.FileInfo after os.ReadDir
Signed-off-by: MOREL Matthieu <matthieu.morel@cnp.fr>
3 years ago
Levi Harrison
a9e2ffb717
Specify type in metadata parser errors ( #10269 )
3 years ago
beorn7
c954cd9d1d
Move packages out of deprecated pkg directory
...
This creates a new `model` directory and moves all data-model related
packages over there:
exemplar labels relabel rulefmt textparse timestamp value
All the others are more or less utilities and have been moved to `util`:
gate logging modetimevfs pool runtime
Signed-off-by: beorn7 <beorn@grafana.com>
3 years ago
Mateusz Gozdek
1a6c2283a3
Format Go source files using 'gofumpt -w -s -extra'
...
Part of #9557
Signed-off-by: Mateusz Gozdek <mgozdekof@gmail.com>
3 years ago
Julien Pivotto
6c56a1faaa
Testify: move to require ( #8122 )
...
* Testify: move to require
Moving testify to require to fail tests early in case of errors.
Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
* More moves
Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
4 years ago
Julien Pivotto
4e5b1722b3
Move away from testutil, refactor imports ( #8087 )
...
Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
4 years ago
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>
5 years ago
Brian Brazil
94b1af1471
Update to disallow new Go 1.13 float formats. ( #5984 )
...
Don't inadvertantly expand the acceptable ways to specify
a float.
Signed-off-by: Brian Brazil <brian.brazil@robustperception.io>
5 years ago
Bartek Plotka
f0863a604e
Removed extra tsdb/testutil after merge.
...
Signed-off-by: Bartek Plotka <bwplotka@gmail.com>
5 years ago
Chris Marchbanks
529ccff07b
Remove all usages of stretchr/testify
...
Signed-off-by: Chris Marchbanks <csmarchbanks@gmail.com>
5 years ago
Giedrius Statkevičius
10ec2552af
promparse: sort all labels when parsing ( #5372 )
...
* promparse: sort all labels when parsing
Some label names might start with an uppercase letter in which case it
needs to come before __name__. Without this it means that we are not
maintaining the same invariant that all label names should be sorted in
such cases.
Amend the tests to check this problem automatically. Without the change
the tests do not pass.
Signed-off-by: Giedrius Statkevičius <giedriuswork@gmail.com>
6 years ago
Brian Brazil
3fdb92010e
Expand OM to OpenMetrics
...
Signed-off-by: Brian Brazil <brian.brazil@robustperception.io>
6 years ago
Brian Brazil
c271ef456a
Add an OpenMetrics parser.
...
This is based on the existing parser, and has slightly better
performance (few %) than it.
Signed-off-by: Brian Brazil <brian.brazil@robustperception.io>
6 years ago
Brian Brazil
ffe7efb411
Prepare for multiple text formats
...
Pass content type down to text parser.
Add layer of indirection in front of text parser,
and rename to avoid future clashes.
Signed-off-by: Brian Brazil <brian.brazil@robustperception.io>
6 years ago
Brian Brazil
70c98a06f1
Handle empty HELP in text parser. ( #4444 )
...
Fixes #4427
Signed-off-by: Brian Brazil <brian.brazil@robustperception.io>
6 years ago
Fabian Reinartz
5fcc5b6028
pkg/textparse: support null bytes in comments and help
...
Signed-off-by: Fabian Reinartz <freinartz@google.com>
7 years ago
Fabian Reinartz
76a4a46cb0
pkg/textparse: refactor and add metadata handling
...
Extends the parser to allow retrieving metadata.
The lexer now yields proper tokens that are fed into a hand-written
parser on top.
Signed-off-by: Fabian Reinartz <freinartz@google.com>
7 years ago
Filip Ochnik
ec1c6b7c29
textparse: reject empty label names
7 years ago
Julius Volz
c3d6abc8e6
Fix some lint errors ( #3334 )
...
I left the promql ones and some others untouched as I remember that @fabxc
prefers them that way.
7 years ago
Goutham Veeramachaneni
11ee713ced
Handle common escape characters properly. ( #2995 )
...
Fixes #2974
Signed-off-by: Goutham Veeramachaneni <cs14btech11014@iith.ac.in>
7 years ago
Julius Volz
c6f41ce391
Allow metric and label names to begin with underscores ( #2961 )
...
While this is not recommended, it is allowed in our data model
(https://prometheus.io/docs/concepts/data_model/ ).
Fixes https://github.com/prometheus/prometheus/issues/2959
7 years ago
Goutham Veeramachaneni
b7eddbcd98
textparse: Add fuzzing and fix bug caught
...
See https://github.com/cznic/golex/issues/11 for info on the bug
Signed-off-by: Goutham Veeramachaneni <cs14btech11014@iith.ac.in>
7 years ago
Goutham Veeramachaneni
0e78b7e7c8
parser: support spaces everywhere
...
Signed-off-by: Goutham Veeramachaneni <cs14btech11014@iith.ac.in>
7 years ago
Brian Brazil
dd07f693c8
Single quotes are not valid label value delimiters.
8 years ago
Brian Brazil
a6ca391e6e
Reject scrapes with invalid utf-8 label values.
8 years ago
Fabian Reinartz
bdc763f95f
pkg/textparse: allow null bytes in label values
8 years ago
Fabian Reinartz
ea09299ca5
pkg/textparse: handle trailing labels comma ( #2752 )
8 years ago
Fabian Reinartz
f7c5d96e84
pkg/textparse: parse metric names with ':'
8 years ago
Fabian Reinartz
377886b371
pkg/textparse: implement timestamp parsing
8 years ago
Brian Brazil
5c9a6ce747
Add license to files.
...
This should fix CI for dev-2.0.
8 years ago
Fabian Reinartz
fb3ab9bdb7
pkg/textparse: add more benchmarking, align lex defs
8 years ago