11 Commits

Author SHA1 Message Date
Nick Moore
c05ebef306
Implement SanitizeLabelName and Full variant
Rather than removing the previous implementation of SanitizeLabelName,
offer another version named SanitizeFullLabelName that achieved the
desired requirements, without breaking existing Prometheus code.

Update testing to validate correctness of new variant.

Signed-off-by: Nick Moore <nicholas.moore@grafana.com>
2023-02-03 15:28:33 +00:00
Nick Moore
758914e1fb
Fix SanitizeLabelName for certain invalid labels
SanitizeLabelName was not correctly sanitizing label names that:

1. Started with a digit (0-9)
2. Were empty

This commit changes the santization code to catch both of these edge
cases and adds new tests to validate it works correctly in them both. In
the first case, a leading digit will be replaced with an underscore, and
in the latter, the function will return a single underscore.

Signed-off-by: Nick Moore <nicholas.moore@grafana.com>
2023-02-03 08:53:10 +00:00
Julien Pivotto
9a2e93228e
Switch to grafana/regexp everywhere (#10268)
Let's have a consistent library for regexp.

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2022-02-13 00:58:27 +01:00
Mateusz Gozdek
1a6c2283a3 Format Go source files using 'gofumpt -w -s -extra'
Part of #9557

Signed-off-by: Mateusz Gozdek <mgozdekof@gmail.com>
2021-11-02 19:52:34 +01:00
beorn7
094a098ce6 Revert "Revert the /graph changes."
This reverts commit aa43d34a86cf0124a1a8cecc92c544f7f4793d91.

This brings back the /graph changes so that @grandbora can continue to
work on the redirect for backwards compatibility. And other changes
can already take the new /graph parameters into account.
2016-09-03 21:05:23 +02:00
beorn7
aa43d34a86 Revert the /graph changes.
This revert will be reverted once v1.1 is released and has its own
release branch. Since we had already change on top of this, there was
no cleaner way of cutting those changes out.

This commit reverts the following commits:

Revert "Update backend helpers and templates to new url schema"
This reverts commit fc6cdd0611f5eae523c4eb54b74b97a18c174972.

Revert "Refactor graph.js"
This reverts commit 445fac56e07b29bf31b55f34493273ee1c84f9d6.

Revert "Use query parameters in the url"
This reverts commit 3e18d86d8a424e32dfb7584fe4fa751d3126f3f3.

Revert "Point to correct place for GraphLinkForExpression"
This reverts commit 3da825fc76252155aade2bb25203428579df42e8.

Assets are also updated.
2016-09-02 13:59:09 +02:00
Bora Tunca
fc6cdd0611 Update backend helpers and templates to new url schema 2016-08-08 09:52:14 +02:00
beorn7
a7408bfb47 Unify duration parsing
It's actually happening in several places (and for flags, we use the
standard Go time.Duration...). This at least reduces all our
home-grown parsing to one place (in model).
2016-01-29 15:41:50 +01:00
Jimmi Dyson
923f8111d4 Initial Kubernetes discovery
Fixes #904
2015-08-13 10:38:52 +01:00
Fabian Reinartz
183be62f2a util/strutil: do not panic on wrong duration unit. 2015-06-04 14:02:36 +02:00
Fabian Reinartz
0de6edbdfc Move pkg/ to util/ 2015-06-01 21:12:32 +02:00