InfluxDB-Client-for-Arduino icon indicating copy to clipboard operation
InfluxDB-Client-for-Arduino copied to clipboard

ESP32 Console logging to Grafana

Open maxdd opened this issue 3 years ago • 1 comments

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,

maxdd avatar Aug 30 '22 14:08 maxdd

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

vlastahajek avatar Aug 30 '22 20:08 vlastahajek