Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "endpoints" with prometheus compatible metrics #900

Merged
merged 5 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions site/src/prometheus/addons.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
# This file is used to generate the prometheus/addons endpoint
permalink: '/prometheus/addons'
eleventyAllowMissingExtension: true
---
#
# 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 -%}
49 changes: 49 additions & 0 deletions site/src/prometheus/base.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
# This file is used to generate the prometheus/base endpoint
permalink: '/prometheus/base'
eleventyAllowMissingExtension: true
---
#
# 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 %}
21 changes: 21 additions & 0 deletions site/src/prometheus/custom_integrations.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
# This file is used to generate the prometheus/custom_integrations endpoint
permalink: '/prometheus/custom_integrations'
eleventyAllowMissingExtension: true
---
#
# 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 -%}
18 changes: 18 additions & 0 deletions site/src/prometheus/integrations.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
# This file is used to generate the prometheus/integrations endpoint
permalink: '/prometheus/integrations'
eleventyAllowMissingExtension: true
---
#
# 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 -%}