Skip to content

Commit

Permalink
Switch to using config file
Browse files Browse the repository at this point in the history
  • Loading branch information
emphoeller committed Jul 8, 2024
1 parent c1426a5 commit b23273f
Show file tree
Hide file tree
Showing 5 changed files with 405 additions and 85 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/config
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ RUN ln -st /usr/local/bin/ /coturn_exporter_files/coturn_exporter

USER nobody:nogroup

ENTRYPOINT []
CMD ["coturn_exporter"]
ENTRYPOINT ["coturn_exporter"]
CMD []

EXPOSE 9524/tcp
86 changes: 77 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,92 @@
# Coturn Exporter

Tests whether a given TURN server is working and exports the result as a Prometheus metric
Tests whether TURN servers are working and exports the result as a Prometheus metric

## How to Run It

```bash
docker build -t coturn_exporter .
docker run -e IP=1.2.3.4 -e PORT=1234 -e SECRET=qwerty -e INTERVAL=600 -e LOGLEVEL=INFO -p 127.0.0.1:80:9524 coturn_exporter
echo 'ip: 1.2.3.4' > config # Replace with your TURN server's IP; see below for port, secret, and more
docker run \
--mount type=bind,src="$(pwd)"/config,dst=/coturn_exporter_files/config,readonly \
-p 127.0.0.1:80:9524 coturn_exporter
```

All environment variables except `IP` are optional. `INTERVAL` (how many seconds to wait between checks) defaults to 900. `IP`, `PORT`, and `SECRET` refer to the TURN server to be checked. `LOGLEVEL` can be one of `DEBUG`, `INFO`, `WARNING`, `ERROR`, or `CRITICAL` and defaults to `WARNING`.
## The Configuration File

You must mount a configuration file into the container at `/coturn_exporter_files/config` to specify the TURN server(s) to be checked and optionally other settings. Its format is YAML.

### `ip`, `port`, and `secret`

If you have only one TURN server to check, you can specify its IP and optionally its port and/or secret at the root level of the config file.

```yaml
ip: 1.2.3.4
port: 1234
secret: qwerty
```
If no port is specified, 3478 is assumed.
### `turn_servers`

It is possible to specify more than one TURN server with the `turn_servers` key.

```yaml
turn_servers:
- ip: 1.2.3.4
port: 1234
secret: qwerty
- ip: 9.8.7.6
port: 9876
secret: asdf
```

You must use exactly one of `turn_servers` and `ip` \[+ `port`] \[+ `secret`] at the root level.

### `interval`

The optional key `interval` specifies the wait time between checks of each TURN server in seconds. It defaults to 900.

```yaml
interval: 333.33
```

### `loglevel`

The optional key `loglevel` specifies the verbosity of the Coturn Exporter. It can be one of `DEBUG`, `INFO`, `WARNING`, `ERROR`, or `CRITICAL` and defaults to `WARNING`.

```yaml
loglevel: INFO
```

### A Complete Example

```yaml
---
loglevel: INFO
interval: 333.33
turn_servers:
- ip: 1.2.3.4
port: 1234
secret: qwerty
- ip: 9.8.7.6
port: 9876
secret: asdf
...
```

## Output

Metrics are exported on port 9524. They will include something like the following (plus some metrics added by the [Prometheus Python client](https://github.com/prometheus/client_python)):
Metrics are exported on port 9524. They will look like the following (plus some metrics added by the [Prometheus Python client](https://github.com/prometheus/client_python)):

```
# HELP turn_server_state the state of the TURN server
# TYPE turn_server_state gauge
turn_server_state{turn_server_state="ok"} 1.0
turn_server_state{turn_server_state="not_ok"} 0.0
turn_server_state{turn_server_state="unknown"} 0.0
# HELP turnserver_state the state of the TURN server
# TYPE turnserver_state gauge
turnserver_state{host="1.2.3.4:1234",turnserver_state="ok"} 1.0
turnserver_state{host="1.2.3.4:1234",turnserver_state="not_ok"} 0.0
turnserver_state{host="1.2.3.4:1234",turnserver_state="unknown"} 0.0
turnserver_state{host="9.8.7.6:9876",turnserver_state="ok"} 0.0
turnserver_state{host="9.8.7.6:9876",turnserver_state="not_ok"} 1.0
turnserver_state{host="9.8.7.6:9876",turnserver_state="unknown"} 0.0
```
Loading

0 comments on commit b23273f

Please sign in to comment.