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

trouble finding the right yaml #99

Open
Simoliv opened this issue Oct 16, 2022 · 2 comments
Open

trouble finding the right yaml #99

Simoliv opened this issue Oct 16, 2022 · 2 comments

Comments

@Simoliv
Copy link

Simoliv commented Oct 16, 2022

HI there,

please apologize, I seem to be unable to find thr right settings for the exporter .. But .. the documentation could be a bit clearer IMO, some more examples would helped me maybe.

Can anybody guide me in the right direction ? I am having

hoymiles/111817603175/pf 0.999   
hoymiles/111816703175/frequency 49.97   
hoymiles/111816703175/temperature 57.8    
hoymiles/111816703175/total 275.775   
hoymiles/111816703175/emeter/0/power 636.8   
hoymiles/111816703175/emeter/0/voltage 237.6   
hoymiles/111816703175/emeter/0/current 2.68   
hoymiles/111816703175/emeter-dc/0/total 70.852   
hoymiles/111816703175/emeter-dc/0/power 253.6
hoymiles/111816703175/emeter-dc/0/voltage 38.8
hoymiles/111816703175/emeter-dc/0/current 6.54
hoymiles/111816703175/emeter-dc/1/total 72.247
hoymiles/111816703175/emeter-dc/1/power 262.1
hoymiles/111816703175/emeter-dc/1/voltage 38.8
hoymiles/111816703175/emeter-dc/1/current 6.76
hoymiles/111816703175/emeter-dc/2/total 69.769
hoymiles/111816703175/emeter-dc/2/power 109.2
hoymiles/111816703175/emeter-dc/2/voltage 43.5
hoymiles/111816703175/emeter-dc/2/current 2.51
hoymiles/111816703175/emeter-dc/3/total 62.91
hoymiles/111816703175/emeter-dc/3/power 45.4
hoymiles/111816703175/emeter-dc/3/voltage 43.5
hoymiles/111816703175/emeter-dc/3/current 1.04

in mosquitto, and would like to get that into prometheus .. What does my config.yaml need to look like ? The best I was able to achieve was a

2022-10-16T16:39:43Z error cmd/mqtt2prometheus.go:158 Error while processing message {"error": "could not store metrics '275.798' on topic hoymiles/111816703175/total: failed to extract metric values from topic: failed to find valid metric in topic path"}

and some more of this kind of messages..

any help would really be appreciated, best regards

@wmoss
Copy link

wmoss commented Dec 29, 2022

I don't think this is documented anywhere, but the default configuration assumes the values coming from mqtt are json. Since you have only single metric values, you need to set metric_per_topic_config in your config.yaml. That expects a single key called metric_name_regex that contains a regex that runs on the topic to produce the metric name. It must have a named group for metricname.

I haven't tested this, but I'm guessing adding something like this might work.

mqtt:
  metric_per_topic_config:
    metric_name_regex: (.*/)?(?P<metricname>.*)

Have a look around config.go for more info.

@wmoss
Copy link

wmoss commented Dec 29, 2022

Also, have a look at #96, it's a similar issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants