tobiasschuerg / InfluxDB-Client-for-Arduino

Simple library for sending measurements to an InfluxDB with a single network request. Supports ESP8266 and ESP32.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ESP32 Console logging to Grafana

maxdd opened this issue · comments

commented

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,