Skip to content

Map JSON properties as MQTT labels #172

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

SuperCoolAlan
Copy link

Implements the feature requested here: #74

@@ -24,6 +24,7 @@ func NewJSONObjectExtractor(p Parser) Extractor {
return func(topic string, payload []byte, deviceID string) (MetricCollection, error) {
var mc MetricCollection
parsed := gojsonq.New(gojsonq.SetSeparator(p.separator)).FromString(string(payload))
rawPayload := gojsonq.New(gojsonq.SetSeparator(p.separator)).FromString(string(payload))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than parse the raw data again, can we avoid cloning altogether or at least clone the object without deserializing again?

@SuperCoolAlan
Copy link
Author

I should probably update the README to include this new feature, as well :)

@SuperCoolAlan
Copy link
Author

Here's a pre-built package for your use https://github.com/SuperCoolAlan/mqtt2prometheus/pkgs/container/mqtt2prometheus

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.

1 participant