From d76c18852651dd6345f97c410b8d8891da28b0a7 Mon Sep 17 00:00:00 2001 From: ludeeus Date: Sun, 13 Oct 2024 08:36:12 +0000 Subject: [PATCH 1/2] Add "endpoints" with prometheus compatible metrics --- site/src/prometheus/addons.liquid | 22 +++++++++ site/src/prometheus/base.liquid | 48 +++++++++++++++++++ .../src/prometheus/custom_integrations.liquid | 20 ++++++++ site/src/prometheus/integrations.liquid | 17 +++++++ 4 files changed, 107 insertions(+) create mode 100644 site/src/prometheus/addons.liquid create mode 100644 site/src/prometheus/base.liquid create mode 100644 site/src/prometheus/custom_integrations.liquid create mode 100644 site/src/prometheus/integrations.liquid diff --git a/site/src/prometheus/addons.liquid b/site/src/prometheus/addons.liquid new file mode 100644 index 00000000..f71d15e1 --- /dev/null +++ b/site/src/prometheus/addons.liquid @@ -0,0 +1,22 @@ +--- +# This file is used to generate the prometheus/addons endpoint +permalink: '/prometheus/addons' +--- +# +# Example usage: +# - job_name: "homeassistant_analytics_addons" +# scrape_interval: 1h +# metrics_path: /prometheus/addons +# scheme: https +# static_configs: +# - targets: ["analytics.home-assistant.io"] +# + +{%- for addon in addons %} +addon_total{slug="{{addon[0]}}"} {{addon[1]["total"]}} +addon_auto_update{slug="{{addon[0]}}"} {{addon[1]["auto_update"]}} +addon_protected{slug="{{addon[0]}}"} {{addon[1]["protected"]}} +{%- for version in addon[1]["versions"] %} +addon_version{slug="{{addon[0]}}",version="{{version[0]}}"} {{version[1]}} +{%- endfor %} +{%- endfor -%} diff --git a/site/src/prometheus/base.liquid b/site/src/prometheus/base.liquid new file mode 100644 index 00000000..836e6d9c --- /dev/null +++ b/site/src/prometheus/base.liquid @@ -0,0 +1,48 @@ +--- +# This file is used to generate the prometheus/base endpoint +permalink: '/prometheus/base' +--- +# +# Example usage: +# - job_name: "homeassistant_analytics_base" +# scrape_interval: 1h +# metrics_path: /prometheus/base +# scheme: https +# static_configs: +# - targets: ["analytics.home-assistant.io"] +# +instances {{ data.history.last.active_installations }} +{%- for installation_types in data.current.installation_types %} +installation_type{type="{{ installation_types[0] }}"} {{ installation_types[1] }} +{%- endfor %} + +reports_addons {{ data.current.reports_addons }} +reports_integrations {{ data.current.reports_integrations }} +reports_statistics {{ data.current.reports_statistics }} + +median_addons_count {{ data.current.avg_addons }} +median_automations_count {{ data.current.avg_automations }} +median_integrations_count {{ data.current.avg_integrations }} +median_states_count {{ data.current.avg_states }} +median_users_count {{ data.current.avg_users }} + +{% for country in data.current.countries %} +country{code="{{ country[0] }}"} {{ country[1] }} +{%- endfor %} + +{% for version in data.current.versions %} +version{version="{{ version[0] }}"} {{ version[1] }} +{%- endfor %} + +supervisor_unhealthy {{ data.current.supervisor["unhealthy"] }} +supervisor_unsupported {{ data.current.supervisor["unsupported"] }} +{% for arch in data.current.supervisor["arch"] %} +supervisor_arch{arch="{{ arch[0] }}"} {{ arch[1] }} +{%- endfor %} + +{% for board in data.current.operating_system["boards"] %} +operating_system_board{board="{{ board[0] }}"} {{ board[1] }} +{%- endfor %} +{% for version in data.current.operating_system["versions"] %} +operating_system_version{version="{{ version[0] }}"} {{ version[1] }} +{%- endfor %} diff --git a/site/src/prometheus/custom_integrations.liquid b/site/src/prometheus/custom_integrations.liquid new file mode 100644 index 00000000..fb30961b --- /dev/null +++ b/site/src/prometheus/custom_integrations.liquid @@ -0,0 +1,20 @@ +--- +# This file is used to generate the prometheus/custom_integrations endpoint +permalink: '/prometheus/custom_integrations' +--- +# +# Example usage: +# - job_name: "homeassistant_analytics_custom_integrations" +# scrape_interval: 1h +# metrics_path: /prometheus/custom_integrations +# scheme: https +# static_configs: +# - targets: ["analytics.home-assistant.io"] +# + +{%- for integration in custom_integrations %} +custom_integration{domain="{{ integration[0] }}"} {{ integration[1]["total"] }} +{%- for version in integration[1]["versions"] %} +custom_integration_version{domain="{{ integration[0] }}",version="{{version[0]}}"} {{ version[1] }} +{%- endfor -%} +{%- endfor -%} diff --git a/site/src/prometheus/integrations.liquid b/site/src/prometheus/integrations.liquid new file mode 100644 index 00000000..79b35cd6 --- /dev/null +++ b/site/src/prometheus/integrations.liquid @@ -0,0 +1,17 @@ +--- +# This file is used to generate the prometheus/integrations endpoint +permalink: '/prometheus/integrations' +--- +# +# Example usage: +# - job_name: "homeassistant_analytics_integrations" +# scrape_interval: 1h +# metrics_path: /prometheus/integrations +# scheme: https +# static_configs: +# - targets: ["analytics.home-assistant.io"] +# + +{%- for integration in data.current.integrations %} +integration{domain="{{ integration[0] }}"} {{ integration[1] }} +{%- endfor -%} From e377de6fa3f3b18e0cc3c27de3b348268dfcebf3 Mon Sep 17 00:00:00 2001 From: ludeeus Date: Sun, 13 Oct 2024 08:42:11 +0000 Subject: [PATCH 2/2] Fix build --- site/src/prometheus/addons.liquid | 1 + site/src/prometheus/base.liquid | 1 + site/src/prometheus/custom_integrations.liquid | 1 + site/src/prometheus/integrations.liquid | 1 + 4 files changed, 4 insertions(+) diff --git a/site/src/prometheus/addons.liquid b/site/src/prometheus/addons.liquid index f71d15e1..f2761c30 100644 --- a/site/src/prometheus/addons.liquid +++ b/site/src/prometheus/addons.liquid @@ -1,6 +1,7 @@ --- # This file is used to generate the prometheus/addons endpoint permalink: '/prometheus/addons' +eleventyAllowMissingExtension: true --- # # Example usage: diff --git a/site/src/prometheus/base.liquid b/site/src/prometheus/base.liquid index 836e6d9c..2161c066 100644 --- a/site/src/prometheus/base.liquid +++ b/site/src/prometheus/base.liquid @@ -1,6 +1,7 @@ --- # This file is used to generate the prometheus/base endpoint permalink: '/prometheus/base' +eleventyAllowMissingExtension: true --- # # Example usage: diff --git a/site/src/prometheus/custom_integrations.liquid b/site/src/prometheus/custom_integrations.liquid index fb30961b..7f435cf4 100644 --- a/site/src/prometheus/custom_integrations.liquid +++ b/site/src/prometheus/custom_integrations.liquid @@ -1,6 +1,7 @@ --- # This file is used to generate the prometheus/custom_integrations endpoint permalink: '/prometheus/custom_integrations' +eleventyAllowMissingExtension: true --- # # Example usage: diff --git a/site/src/prometheus/integrations.liquid b/site/src/prometheus/integrations.liquid index 79b35cd6..513a5d12 100644 --- a/site/src/prometheus/integrations.liquid +++ b/site/src/prometheus/integrations.liquid @@ -1,6 +1,7 @@ --- # This file is used to generate the prometheus/integrations endpoint permalink: '/prometheus/integrations' +eleventyAllowMissingExtension: true --- # # Example usage: