Conversation
…cument. This could be changed to use full OTLP/JSON if someone required. Updated README to include information about data being gauges
| $NG->log->debug("MqttObservations: Processing concept '$concept' for $node") | ||
| if $extra_logging; | ||
|
|
||
| my $ids = $S->nmisng_node->get_inventory_ids( |
There was a problem hiding this comment.
This works. You don't really need full inventory objects because this is just reading.
if you find that this plugin starts causing performance issues it might work better to query the node for all of it's inventory for the concept, using a fields_hash to limit was is returned. ModelData ->next_value() (without calling data() or count()) will use mongo's built in batching to read more efficiently.
eg:
while( my $entry = $md->next_value )
{
my $D = $entry->{data};
| my $plugin_config = NMISNG::Util::loadTable(dir => 'conf', name => 'mqttobservations', conf => $C); | ||
| if (!$plugin_config || ref($plugin_config) ne 'HASH') | ||
| { | ||
| $NG->log->error("MqttObservations: Failed to load conf/mqttobservations.nmis"); |
There was a problem hiding this comment.
$plugin_config will hold the error string for why it failed to load, it might be useful in the log
| { | ||
| eval { | ||
| my $mqtt = Net::MQTT::Simple->new($server); | ||
| $mqtt->login($username,$password); |
There was a problem hiding this comment.
I suggest refactoring the new and login function calls out of the publishMqtt function and into a connectMqtt function which is called at the start of the collect_plugin function so it's not logging in for each message
Sumitting NMIS MQTT Observations for your consideration.
README has details, sends latest data to MQTT as OTEL inspired flat structure, very efficient, many metrics in one message.