docs/en/api/insights.rst
############ ESP Insights ############
ESP Insights is a remote diagnostics solution that allows users to remotely monitor the health of Espressif devices in the field.
Developers normally prefer debugging issues by physically probing them using gdb or observing the logs. This surely helps debug issues, but there are often cases wherein issues are seen only in specific environments under specific conditions. Even things like casings and placement of the product can affect the behavior. A few examples are
Additional information about ESP Insights can be found here <https://insights.espressif.com/>__.
Insights.begin
This initializes the ESP Insights agent.
.. code-block:: arduino
bool begin(const char *auth_key, const char *node_id = NULL, uint32_t log_type = 0xFFFFFFFF, bool alloc_ext_ram = false);
auth_key Auth key generated using Insights dashboardlog_type Type of logs to be captured (value can be a mask of ESP_DIAG_LOG_TYPE_ERROR, ESP_DIAG_LOG_TYPE_WARNING and ESP_DIAG_LOG_TYPE_EVENT)This function will return
Insights.send
Read insights data from buffers and send it to the cloud. Call to this function is asynchronous, it may take some time to send the data.
.. code-block:: arduino
bool sendData()
This function will return
Insights.end
Deinitialize ESP Insights.
.. code-block:: arduino
void end();
Insights.disable
Disable ESP Insights.
.. code-block:: arduino
void disable();
metrics object of Insights class expose API's for using metrics.
Insights.metrics.addX
Register a metric of type X, where X is one of: Bool, Int, Uint, Float, String, IPv4 or MAC
.. code-block:: arduino
bool addX(const char *tag, const char *key, const char *label, const char *path);
tag : Tag of metricskey : Unique key for the metricslabel : Label for the metricspath : Hierarchical path for key, must be separated by '.' for more than one levelThis function will return
Insights.metrics.remove
Unregister a diagnostics metrics
.. code-block:: arduino
bool remove(const char *key);
key : Key for the metricsThis function will return
Insights.metrics.removeAll
Unregister all previously registered metrics
.. code-block:: arduino
bool removeAll();
This function will return
Insights.metrics.setX
Add metrics of type X to storage, where X is one of: Bool, Int, Uint, Float, String, IPv4 or MAC
.. code-block:: arduino
bool setX(const char *key, const void val);
key : Key of metricsval : Value of metricsThis function will return
ESP_OK : On successInsights.metrics.dumpHeap
Dumps the heap metrics and prints them to the console. This API collects and reports metrics value at any give point in time.
.. code-block:: arduino
bool dumpHeap();
This function will return
Insights.metrics.dumpWiFi
Dumps the Wi-Fi metrics and prints them to the console. This API can be used to collect Wi-Fi metrics at any given point in time.
.. code-block:: arduino
bool dumpWiFi();
This function will return
Insights.metrics.setHeapPeriod
Reset the periodic interval By default, heap metrics are collected every 30 seconds, this function can be used to change the interval. If the interval is set to 0, heap metrics collection disabled.
.. code-block:: arduino
void setHeapPeriod(uint32_t period);
period : Period interval in secondsInsights.metrics.setWiFiPeriod
Reset the periodic interval By default, Wi-Fi metrics are collected every 30 seconds, this function can be used to change the interval. If the interval is set to 0, Wi-Fi metrics collection disabled.
.. code-block:: arduino
void setHeapPeriod(uint32_t period);
period : Period interval in secondsvariables object of Insights class expose API's for using variables.
Insights.variables.addX
Register a variable of type X, where X is one of: Bool, Int, Uint, Float, String, IPv4 or MAC
.. code-block:: arduino
bool addX(const char *tag, const char *key, const char *label, const char *path);
tag : Tag of variablekey : Unique key for the variablelabel : Label for the variablepath : Hierarchical path for key, must be separated by '.' for more than one levelThis function will return
Insights.variables.remove
Unregister a diagnostics variable
.. code-block:: arduino
bool remove(const char *key);
key : Key for the variableThis function will return
Insights.variables.removeAll
Unregister all previously registered variables
.. code-block:: arduino
bool unregisterAll();
This function will return
Insights.variables.setX
Add variable of type X to storage, where X is one of: Bool, Int, Uint, Float, String, IPv4 or MAC
.. code-block:: arduino
bool setX(const char *key, const void val);
key : Key of metricsval : Value of metricsThis function will return
To get started with Insights, you can try:
.. literalinclude:: ../../../libraries/Insights/examples/MinimalDiagnostics/MinimalDiagnostics.ino :language: arduino