tobiasschuerg / InfluxDB-Client-for-Arduino

Simple library for sending measurements to an InfluxDB with a single network request. Supports ESP8266 and ESP32.
MIT License
382 stars 95 forks source link

ESP32 Console logging to Grafana #194

Closed maxdd closed 2 years ago

maxdd commented 2 years ago

Hello, I was wondering whether there is a proper way to send "log text" to influxdb so that it can be used e.g. from a "log panel" to display debugging log messages. The intention for me is to have a sort of uart over grafana or soem sort of "analytics" feature in ESP32.

For example is it sufficient to create a string containing all the information similarly to this picture? https://grafana.com/static/img/docs/explore/navigate-logs-8-0.png

e.g.

    String t = "level=warn msg=\"Setting xyz in function abc\" other=\"you name it\" ID=2849"
    //How to do i write raw from a string to influxdb??

or is it better to use e.g.

    console.clearFields();
    console.addField("level", "warn"); //with or without ""
    console.addField("msg", "Setting xyz in function abc");
    console.addField("other", "you name it");
    console.addField("ID", AppID);

    if (!client.writePoint(sensor)) {
        Serial.print("InfluxDB write failed: ");
        Serial.println(client.getLastErrorMessage());
    }

Can i achieve what i'm looking for in this way? Of course once the backbone is set i would wrap it around e.g.

    Console.write(WARN, AppID, Setting xyz in function abc, ...);

Regards,

vlastahajek commented 2 years ago

This could help you: https://www.influxdata.com/blog/writing-logs-directly-to-influxdb