Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small Loki fixes #12300

Merged
merged 2 commits into from
Sep 22, 2023
Merged

Small Loki fixes #12300

merged 2 commits into from
Sep 22, 2023

Conversation

monstermunchkin
Copy link
Contributor

  • loki: Check return value of reflect.TypeOf()
  • loki: Fix labels names with hyphens

This adds a nil-check for the return type of `reflect.TypeOf()`.

Signed-off-by: Thomas Hipp <thomas.hipp@canonical.com>
Label names in Loki may not contain any hyphens.

Previously, when setting `loki.labels` to `[context-foo]`, the label
name would be set to `context-foo` as well. The entry however would
never be seen in Loki as it was classified as malformend.

With this change, hyphens are replaced with underscores. In the above
example, the label would now be named `context_foo`.

Signed-off-by: Thomas Hipp <thomas.hipp@canonical.com>
@simondeziel
Copy link
Member

For posterity, https://grafana.com/docs/loki/latest/get-started/labels/#format says:

It may contain ASCII letters and digits, as well as underscores and colons. It must match the regex [a-zA-Z_:][a-zA-Z0-9_:]*.
Note: The colons are reserved for user defined recording rules. They should not be used by exporters or direct instrumentation.

@tomponline tomponline merged commit 52c8aa6 into canonical:main Sep 22, 2023
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants