diff options
author | Emmanuel Vasilakis <mrzammler@mm.st> | 2021-04-21 18:24:51 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-21 18:24:51 +0300 |
commit | a1ce482f3e336dbabe1b12b92f6339af6a2bbbf8 (patch) | |
tree | 8ae1e1add384b80988479d36b1f88702e71b48c9 /web | |
parent | b6d729f96a0b1e17abffb2cf69d1ff29e62004f4 (diff) |
Provide more agent analytics to posthog (#10887)
* Move statistics related functions to analytics.c
* error message change, space added after if
* start an analytics thread
* use heartbeat instead of sleep
* add late enviroment (after rrdinit) pick of some attributes
* change loop
* re-enable info messages
* remove possible new line
* log and report hits on allmetrics pages. detect if exporting engines are enabled/in use, and report them
* use lowercase for analytics variables
* add collectors
* add buildinfo
* more attributes from late environment
* add new attributes to v1/info
* re-gather meta data before exit. update allmetrics counters to be available in v1/info
* log hits to dashboard
* add mirrored hosts
* added notification methods
* fix spaces, proper JSON naming
* add alerts, charts and metrics count
* more attributes
* keep the thread up, and report a meta event every 2 hours
* small formating changes. Disable analytics_log_prometheus when for unit testing. Add the new attributes to the anonymous-statistics.sh.in script
* applied clang-format
* dont gather data again on exit
* safe buffer length in snprintfz
* add rrdset lock
* remove show_archived
Diffstat (limited to 'web')
-rw-r--r-- | web/api/exporters/shell/allmetrics_shell.c | 2 | ||||
-rw-r--r-- | web/api/web_api_v1.c | 77 |
2 files changed, 77 insertions, 2 deletions
diff --git a/web/api/exporters/shell/allmetrics_shell.c b/web/api/exporters/shell/allmetrics_shell.c index daa004992f..0b0ce22913 100644 --- a/web/api/exporters/shell/allmetrics_shell.c +++ b/web/api/exporters/shell/allmetrics_shell.c @@ -23,6 +23,7 @@ static inline size_t shell_name_copy(char *d, const char *s, size_t usable) { #define SHELL_ELEMENT_MAX 100 void rrd_stats_api_v1_charts_allmetrics_shell(RRDHOST *host, BUFFER *wb) { + analytics_log_shell(); rrdhost_rdlock(host); // for each chart @@ -92,6 +93,7 @@ void rrd_stats_api_v1_charts_allmetrics_shell(RRDHOST *host, BUFFER *wb) { // ---------------------------------------------------------------------------- void rrd_stats_api_v1_charts_allmetrics_json(RRDHOST *host, BUFFER *wb) { + analytics_log_json(); rrdhost_rdlock(host); buffer_strcat(wb, "{"); diff --git a/web/api/web_api_v1.c b/web/api/web_api_v1.c index 1d8217bbd1..96fcf485ac 100644 --- a/web/api/web_api_v1.c +++ b/web/api/web_api_v1.c @@ -750,6 +750,7 @@ inline int web_client_api_request_v1_registry(RRDHOST *host, struct web_client * if(unlikely(action == 'H')) { // HELLO request, dashboard ACL + analytics_log_dashboard(); if(unlikely(!web_client_can_access_dashboard(w))) return web_client_permission_denied(w); } @@ -995,10 +996,82 @@ inline int web_client_api_request_v1_info_fill_buffer(RRDHOST *host, BUFFER *wb) } #ifdef ENABLE_ACLK if (aclk_connected) - buffer_strcat(wb, "\t\"aclk-available\": true\n"); + buffer_strcat(wb, "\t\"aclk-available\": true,\n"); else #endif - buffer_strcat(wb, "\t\"aclk-available\": false\n"); // Intentionally valid with/without #ifdef above + buffer_strcat(wb, "\t\"aclk-available\": false,\n"); // Intentionally valid with/without #ifdef above + + buffer_strcat(wb, "\t\"memory-mode\": "); + analytics_get_data(analytics_data.netdata_config_memory_mode, wb); + buffer_strcat(wb, ",\n"); + + buffer_strcat(wb, "\t\"multidb-disk-quota\": "); + analytics_get_data(analytics_data.netdata_config_multidb_disk_quota, wb); + buffer_strcat(wb, ",\n"); + + buffer_strcat(wb, "\t\"page-cache-size\": "); + analytics_get_data(analytics_data.netdata_config_page_cache_size, wb); + buffer_strcat(wb, ",\n"); + + buffer_strcat(wb, "\t\"stream-enabled\": "); + analytics_get_data(analytics_data.netdata_config_stream_enabled, wb); + buffer_strcat(wb, ",\n"); + + buffer_strcat(wb, "\t\"hosts-available\": "); + analytics_get_data(analytics_data.netdata_config_hosts_available, wb); + buffer_strcat(wb, ",\n"); + + buffer_strcat(wb, "\t\"https-enabled\": "); + analytics_get_data(analytics_data.netdata_config_https_enabled, wb); + buffer_strcat(wb, ",\n"); + + buffer_strcat(wb, "\t\"buildinfo\": "); + analytics_get_data(analytics_data.netdata_buildinfo, wb); + buffer_strcat(wb, ",\n"); + + buffer_strcat(wb, "\t\"release-channel\": "); + analytics_get_data(analytics_data.netdata_config_release_channel, wb); + buffer_strcat(wb, ",\n"); + + buffer_strcat(wb, "\t\"web-enabled\": "); + analytics_get_data(analytics_data.netdata_config_web_enabled, wb); + buffer_strcat(wb, ",\n"); + + buffer_strcat(wb, "\t\"notification-methods\": "); + analytics_get_data(analytics_data.netdata_notification_methods, wb); + buffer_strcat(wb, ",\n"); + + buffer_strcat(wb, "\t\"exporting-enabled\": "); + analytics_get_data(analytics_data.netdata_config_exporting_enabled, wb); + buffer_strcat(wb, ",\n"); + + buffer_strcat(wb, "\t\"exporting-connectors\": "); + analytics_get_data(analytics_data.netdata_exporting_connectors, wb); + buffer_strcat(wb, ",\n"); + + buffer_strcat(wb, "\t\"allmetrics-prometheus-used\": "); + analytics_get_data(analytics_data.netdata_allmetrics_prometheus_used, wb); + buffer_strcat(wb, ",\n"); + + buffer_strcat(wb, "\t\"allmetrics-shell-used\": "); + analytics_get_data(analytics_data.netdata_allmetrics_shell_used, wb); + buffer_strcat(wb, ",\n"); + + buffer_strcat(wb, "\t\"allmetrics-json-used\": "); + analytics_get_data(analytics_data.netdata_allmetrics_json_used, wb); + buffer_strcat(wb, ",\n"); + + buffer_strcat(wb, "\t\"dashboard-used\": "); + analytics_get_data(analytics_data.netdata_dashboard_used, wb); + buffer_strcat(wb, ",\n"); + + buffer_strcat(wb, "\t\"charts-count\": "); + analytics_get_data(analytics_data.netdata_charts_count, wb); + buffer_strcat(wb, ",\n"); + + buffer_strcat(wb, "\t\"metrics-count\": "); + analytics_get_data(analytics_data.netdata_metrics_count, wb); + buffer_strcat(wb, "\n"); buffer_strcat(wb, "}"); return 0; |