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

twitch exporter not returning any metrics #61

Closed
coolapso opened this issue Jul 20, 2024 · 1 comment
Closed

twitch exporter not returning any metrics #61

coolapso opened this issue Jul 20, 2024 · 1 comment

Comments

@coolapso
Copy link
Contributor

Twitch exporter seems to not collect any metrics nor throw any logs. It also seems to be ignoring some flags as setting --log.level debug results in no extra logs and output seems to confirm so.

[coolapso@nebu]-[~/twitch_exporter]  main go v1.22.5
☸ virt01 ❯go run twitch_exporter.go --log.level debug \
        --twitch.client-id *  \
        --twitch.access-token *  \
        --twitch.channel cool4pso
ts=2024-07-20T14:41:42.026Z caller=twitch_exporter.go:250 level=info msg="Starting twitch_exporter" version="(version=, branch=, revision=unknown)"
ts=2024-07-20T14:41:42.026Z caller=twitch_exporter.go:251 level=info build_context="(go=go1.22.5, platform=linux/amd64, user=, date=, tags=unknown)"
ts=2024-07-20T14:41:42.027Z caller=tls_config.go:313 level=info msg="Listening on" address=[::]:9184
ts=2024-07-20T14:41:42.027Z caller=tls_config.go:316 level=info msg="TLS is disabled." http2=false address=[::]:9184

Metrics:

[coolapso@nebu]-[~/twitch_exporter]  main go v1.22.5
☸ virt01 ❯curl localhost:9184/metrics | grep twitch_
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  6235    0  6235    0     0  11224      0 --:--:-- --:--:-- --:--:-- 11214
# HELP twitch_exporter_build_info A metric with a constant '1' value labeled by version, revision, branch, goversion from which twitch_exporter was built, and the goos and goarch for the build.
# TYPE twitch_exporter_build_info gauge
twitch_exporter_build_info{branch="",goarch="amd64",goos="linux",goversion="go1.22.5",revision="unknown",tags="unknown",version=""} 1

For this I seem to have no clue where to start looking, would appreciate some help, ill be happy to work on it.

@coolapso
Copy link
Contributor Author

coolapso commented Jul 20, 2024

seems to be not returning error properly, added a print just to peak at the response:

func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
	channelsLive := make(map[string]bool)
	streamsResp, err := e.client.GetStreams(&helix.StreamsParams{
		UserLogins: *twitchChannel,
		First:      len(*twitchChannel),
	})
	fmt.Println(streamsResp)
	if err != nil {
		level.Error(e.logger).Log("msg", "Failed to collect stats from Twitch helix API", "err", err)
		return
	}

yelds the following result:

&{{401 map[Content-Length:[69] Content-Type:[application/json; charset=utf-8] Date:[Sat, 20 Jul 2024 14:56:34 GMT] Strict-Transport-Security:[max-age=300] Timing-Allow-Origin:[https://www.twitch.tv] Vary:[Accept-Encoding, Origin] X-Cache:[MISS, MISS] X-Cache-Hits:[0, 0] X-Served-By:[cache-bfi-kbfi7400114-BFI, cache-bma1627-BMA] X-Timer:[S1721487394.244472,VS0,VS0,VE157]] Unauthorized 401 Invalid OAuth token} {[] {}}}

believe this happens because the request is successful therefore err != null ... probably should log if response is not 200

@damoun damoun closed this as completed in 96d7b3e Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant