Skip to content

Commit

Permalink
adds changes suggested in #49
Browse files Browse the repository at this point in the history
  • Loading branch information
denisgolius committed Oct 4, 2024
1 parent 5668243 commit 3bf7f52
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 25 deletions.
46 changes: 29 additions & 17 deletions victoria-metrics/DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@
## Installation and Configuration

### Install the add-on
If you are reading this in the documentation tab of the add-on - you have already completed this step.

If you are reading this in the documentation tab of the add-on - you have already completed this step.

Otherwise:
* Add the reposity. (Quick link: [![Open your Home Assistant instance and show the Supervisor add-on store.](https://my.home-assistant.io/badges/supervisor_store.svg)](https://my.home-assistant.io/redirect/supervisor_store/) )
* Add the reposity (click 3 dots on the top right of the screen). Reposity URL: *https://github.com/VictoriaMetrics-Community/homeassistant-addon-victoriametrics*
* Refresh/reload your browser tab/window
* Install the add-on:
* Find, and **install** the VictoriaMetrics Add-on
* Add the reposity (click 3 dots on the top right of the screen). Reposity URL: *https://github.com/VictoriaMetrics-Community/homeassistant-addon-victoriametrics*
* Refresh/reload your browser tab/window
* Install the add-on
* Find, and **install** the VictoriaMetrics Add-on

### Steps to get everything running

Once the add-on is installed:

* Read the add-on documentation
Expand All @@ -23,23 +26,32 @@ Once the add-on is installed:


## Data Storage
VictoriaMetrtics Data is stored in folder /share/victoria-metrics-data of Home Assistant OS to make individual backups easy.

VictoriaMetrtics Data is stored in folder /share/victoria-metrics-data of Home Assistant OS to make individual backups easy.

## Configuration

### Retention

To define the retention, that is how long VictoriaMetrics will keep it's data, set it to a number in months. You can also use value like for example `30d`, `6m` or `3y`.

See: https://github.com/VictoriaMetrics/VictoriaMetrics#retention

### Additional arguments
### Scrape Targets

You can add scrape targets by creating a yaml configuration
file in the `addons_config/victoria_metrics` folder.
Set the `prometheusScrapeConfig` option to the filename of the configuration file.

### Extra Victoria Metrics Arguments

You can use advanced configuration options of VictoriaMetrics using parameters.
As an example add HomeAssistant SSL certificates using the following option:

```-tls -tlsCertFile=/ssl/fullchain.pem -tlsKeyFile=/ssl/privkey.pem```

### Sending data to VictoriaMetrics

To send data from Home Assistant to VictoriaMetrics, you can use the `InfluxDB` integration.
Add the following code to your `configuration.yaml` to have a basic setup. (And, of course, restart Home Assistant.)
With the option `measurement_attr: entity_id` you will get the `entity_id` as metric name what is great in combination with Grafana - just one click and you get the data you want. In Grafana you can use the prometheus data source to get access to your time series data. Have fun!
Expand Down Expand Up @@ -153,18 +165,19 @@ Finally check the `prometheus.yml` of this addon and adjust IP of your installat
Also make sure to create a long-living token as `bearer_token` for authentication.
-->


### Grafana

#### Setup data source
#### Setup a data source

Select Prometheus as Data Source with the following parameters (the URL must include the *http://* prefix):
Select Prometheus as Data Source with the following parameters (the URL must include the `http://` prefix):

HTTP / Field: URL
```http://YOUR_HOMEASSISTANT_IP_ADDRESS:8428/prometheus```
**HTTP / Field: URL**

HTTP / Field: Access
```Server (default)```
`http://YOUR_HOMEASSISTANT_IP_ADDRESS:8428/prometheus`

**HTTP / Field: Access**

`Server (default)`

This is all the configuration that is required. There are no user accounts, tokens or secrets to be setup.

Expand All @@ -173,19 +186,18 @@ This is all the configuration that is required. There are no user accounts, toke
To get a graph in your dashboard you just have to add a panel.
Then click on `Metric` in the Query UI and start typing for example `livi temp` to find the entity `sensor.livingroom_temperature_value` and show the temperature graph after pressing the blue button `Run queries` or `Apply`.


#### Show friendly names

After adding a entity to your graph you will probably change the long text in the legend to a more readable one.
You can do this for all metrics/entities in the panel at once:

Sidebar / Standard Options / Field: Display name
```${__field.labels.friendly_name}```
`${__field.labels.friendly_name}`

Or you can only change the name of one metric/entity:

Query / Field: Legend
```{{friendly_name}}```
`{{friendly_name}}`

### Graphite

Expand Down
4 changes: 3 additions & 1 deletion victoria-metrics/config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Victoria Metrics
version: "1.9.2"
version: "1.9.4"
slug: victoria_metrics
description: Time Series Database for long term storage as replacement for Prometheus and InfluxDB
webui: "http://[HOST]:[PORT:8428]/"
Expand All @@ -22,6 +22,7 @@ init: false
map:
- share:rw
- ssl
- addon_config
options:
retention: "99y"
additionalArguments: ""
Expand All @@ -46,3 +47,4 @@ schema:
prometheusScrapeTimeout: "str?"
longelivedToken: "password?"
homeassistantUrl: "str?"
prometheusScrapeConfig: "str?"
11 changes: 8 additions & 3 deletions victoria-metrics/start-victoria-metrics
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fi
PROMETHEUSARGS=""
if bashio::config.true 'enablePrometheusScrape'
then
bashio::log.info "Use promscrape config for Victoria Metrics"
bashio::log.info "Adding promscrape config for VictoriaMetrics"
SCHEME="http"
if bashio::config.true 'prometheusScrapeHTTPS'
then
Expand All @@ -25,7 +25,12 @@ then
PROMETHEUSARGS="-promscrape.config /prometheus.yml"
fi

if ! bashio::config.is_empty 'prometheusScrapeConfig'
then
bashio::log.info "Adding user defined promscrape config"
PROMETHEUSARGS="$PROMETHEUSARGS -promscrape.config /config/$(bashio::config 'prometheusScrapeConfig')"
fi

bashio::log.info "Starting Victoria Metrics with retention set to $RETENTION"
bashio::log.info "Starting Victoria Metrics with args set to $ARGS"
bashio::log.info "Starting VictoriaMetrics with retention set to $RETENTION"
bashio::log.info "Starting VictoriaMetrics with args set to $ARGS"
"/victoria-metrics-prod" "-storageDataPath" "/share/victoria-metrics-data" -retentionPeriod $RETENTION $HTTPAUTHARGS $PROMETHEUSARGS $ARGS
15 changes: 11 additions & 4 deletions victoria-metrics/translations/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ configuration:
description: Defines the retention in month to store data. You can also use years or days for example `2y` or `30d`.
additionalArguments:
name: Additional Arguments
description: Defines additional arguments, checkout https://github.com/VictoriaMetrics/VictoriaMetrics or the Victoria Metrics documentation.
description: Defines additional arguments, checkout https://github.com/VictoriaMetrics/VictoriaMetrics or the VictoriaMetrics documentation.
enableHTTPAuth:
name: Enable HTTPAuth
description: If set to true, the Username and Password are used as basicAuth/httpAuth in front of Victoria Metrics.
description: If set to true, the Username and Password are used as basicAuth/httpAuth in front of VictoriaMetrics.
username:
name: Username
description: Username for the basicAuth/httpAuth (has no effect if HTTPAuth is not enabled).
password:
name: Password
description: Password for the basicAuth/httpAuth (has no effect if HTTPAuth is not enabled).
enablePrometheusScrape:
name: Enable Prometheus scrape
description: If set to true, a Prometheus scrape for Home Assistant will be configured in Victoria Metrics. https://www.home-assistant.io/integrations/prometheus
name: Add a Prometheus scrape target for Home Assistant
description: If set to true, a Prometheus scrape for Home Assistant will be configured in VictoriaMetrics. https://www.home-assistant.io/integrations/prometheus
prometheusScrapeHTTPS:
name: Use HTTPS Prometheus scrape
description: Set to true if you use a HTTPS connection for your Home Assistant.
Expand All @@ -32,3 +32,10 @@ configuration:
homeassistantUrl:
name: Home Assistant URL
description: Home Assistant URL incl. port for Prometheus scrape (example "homeassistant:8123") (has no effect if Prometheus scrape is not enabled).
prometheusScrapeConfig:
name: Prometheus scrape configuration file
description: |
The name of a prometheus scrape configuration file.
See [VictoriaMetrics Docs](https://docs.victoriametrics.com/single-server-victoriametrics/#how-to-scrape-prometheus-exporters-such-as-node-exporter)
and [scrape config examples](https://docs.victoriametrics.com/scrape_config_examples) for more information.
Create this file in the `addons_config/victoria_metrics` directory to add additional scrape targets.

0 comments on commit 3bf7f52

Please sign in to comment.