Prometheus Twitch Exporter
1.1K
Prometheus twitch exporter to monitor twitch streams with prometheus. With support Oauth support, for both user and application tokens.
Currently you can only grab one of the binaries provided in the releases page, or run it using docker. Check each use case examples for more details.
| Metric | Meaning | Labels | type |
|---|---|---|---|
| twitch_is_live | If twitch channel is broadcasting | name | gauge |
| twitch_viewer_total | Channel current viewer count | name | gauge |
| twitch_channel_followers_total | The number of channel followers | name | gauge |
| twitch_channel_subscribers_total | The number of channel subscribers | name | gauge |
Usage:
twitch-exporter [flags]
Flags:
--access.token string twitch user access token
--address string The address to access the exporter used for oauth redirect uri (default "localhost")
--client.id string twitch client id
--client.secret string twitch client secret
-h, --help help for twitch-exporter
--listen.port string Port to listen at (default "9184")
--log.format string Exporter log format, text or json (default "text")
--log.level string Exporter log level (default "info")
--metrics.path string Path to expose metrics at (default "/metrics")
--refresh.token string twitch refresh token
--twitch.channels strings List of channels to get basic metrics from
--twitch.user string The user associated with the user token to get extra metrics from
--user.token If going to use the provided token as a user token
You can also use environment variables. The most accurate list for them is available here.
Twitch provides two types of authentication methods:
When using an application token, you are only granted access to some generic public endpoints. This exporter can only gather a basic set of metrics from any channel available on Twitch.
http://<exporterAddress>:9184.--client.id <ClientID>, --client.secret <ClientSecret>, and the --twitch.channels <ChannelsList> you wish to monitor.http://<exporterAddress>:9184/metrics.Using flags:
./twitch-exporter --client.id <ClientID> --client.secret <ClientSecret> --twitch.channels "chan1,chan2,chan3"
Using environment variables:
TWITCH_CLIENT_ID="<ClientID>" TWITCH_CLIENT_SECRET="<ClientSecret>" TWITCH_CHANNELS="chan1 chan2 chan3" ./twitch-exporter
With Docker, using flags:
docker run -d -p 9184:9184 \
coolapso/twitch-exporter \
--client.id=<ClientID> \
--client.secret=<ClientSecret> \
--twitch.channels="chan1,chan2,chan3"
With Docker, using environment variables:
docker run -d -p 9184:9184 \
-e TWITCH_CLIENT_ID=<ClientID> \
-e TWITCH_CLIENT_SECRET=<ClientSecret> \
-e TWITCH_CHANNELS="chan1 chan2 chan3" \
coolapso/twitch-exporter
When using user tokens, you are granted access to all features and metrics available for application tokens, plus information specific to your own channel/username.
--client.id <ClientID>, --client.secret <ClientSecret>, set the --user.token flag, and provide the username associated with the OAuth token with the --twitch.user <UserName>.http://<ExporterAddress>:9184/ and complete the authentication flow.Using flags:
./twitch-exporter --client.id <ClientID> --client.secret <ClientSecret> --twitch.channels "chan1,chan2,chan3" --user.token --twitch.user cool4pso
Using environment variables:
TWITCH_CLIENT_ID="<ClientID>" TWITCH_CLIENT_SECRET="<ClientSecret>" TWITCH_USER_TOKEN=true TWITCH_USER=cool4pso TWITCH_CHANNELS="chan1 chan2 chan3" ./twitch-exporter
With Docker, using flags:
docker run -d -p 9184:9184 \
coolapso/twitch-exporter \
--address="192.168.1.5"
--client.id=<ClientID> \
--client.secret=<ClientSecret> \
--twitch.channels="chan1,chan2,chan3" \
--user.token \
--twitch.user cool4pso
With Docker, using environment variables:
docker run -d -p 9184:9184 \
-e ADDRESS="192.168.1.5"
-e TWITCH_CLIENT_ID=<ClientID> \
-e TWITCH_CLIENT_SECRET=<ClientSecret> \
-e TWITCH_CHANNELS="chan1 chan2 chan3" \
-e TWITCH_USER_TOKEN=true \
coolapso/twitch-exporter
You can also pre-generate the access token and refresh token, for example with Twitch CLI:
twitch token get -u --scopes "channel:read:subscriptions"
Then provide them to the application using the flags or corresponding environment variables. This way, you won't have to handle the authentication flow every time.
Improvements and suggestions are always welcome, feel free to check for any open issues, open a new Issue or Pull Request
If you like this project and want to support / contribute in a different way you can always :heart: Sponsor Me or
Content type
Image
Digest
sha256:995e840b3…
Size
12.9 MB
Last updated
almost 2 years ago
docker pull coolapso/twitch-exporter