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

Make GroupValue() more resilient #47

Merged
merged 1 commit into from
Mar 6, 2021

Conversation

chr4
Copy link
Contributor

@chr4 chr4 commented Mar 6, 2021

When sending a topic that doesn't match the configured regex, mqtt2prometheus currently just crashes.

This can be reproduced by using this config and then publishing a message to shellies/test:

mqtt:
  server: tcp://mosquitto:1883
  topic_path: shellies/#
  device_id_regex: "shellies/(?P<deviceid>.*)/sensor"
  metric_per_topic_config:
    metric_name_regex: "shellies/(?P<deviceid>.*)/sensor/(?P<metricname>.*)"

This patch ignores topic not parseable by the regex instead and outputs the following error instead:

error        cmd/mqtt2prometheus.go:119        Error while processing message
{"error": "could not store metrics '' on topic shellies/test: failed to extract metric values from topic: failed to find valid metric in topic path"}

@hikhvar hikhvar merged commit 8319830 into hikhvar:master Mar 6, 2021
@chr4 chr4 deleted the feat/topic-resillience branch March 6, 2021 22:39
@chr4 chr4 restored the feat/topic-resillience branch March 6, 2021 22:39
@chr4
Copy link
Contributor Author

chr4 commented Mar 6, 2021

Thanks for merging so quickly!

Is there a release planned with this fix?

@hikhvar
Copy link
Owner

hikhvar commented Mar 6, 2021

In short yes. I'm currently writing some regression test for this and other functions.

@hikhvar
Copy link
Owner

hikhvar commented Mar 6, 2021

I just tagged the current master with v0.1.6-RC3. After the github action run the new release should be ready.
For a v0.1.6 release I want to switch to a rootless Docker image.

@hikhvar
Copy link
Owner

hikhvar commented Mar 7, 2021

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.

2 participants