peimanja / artifactory_exporter

JFrog Artifactory Prometheus Exporter written in Go
Apache License 2.0
141 stars 37 forks source link

Log format doesn't change anything #69

Closed Feriman22 closed 2 years ago

Feriman22 commented 2 years ago

Dear Developer,

I run this software on our server, but the output on the servername:9531/metrics site doesn't change at all.

I tried to run it with these ways:

./artifactory_exporter
./artifactory_exporter --log.format=json
./artifactory_exporter --log.format=logfmt

We got same format as an output for all methods. The target is reading these infos by Grafana, but the error is this below at this moment, while trying to add Prometheus data source: Error reading Prometheus: bad_response: readObjectStart: expect { or n, but found <, error found in #1 byte of ...|<html> |..., bigger context ...|<html> <head><title>JFrog Artifactory |...

What am I doing wrong?

Thanks! Feriman

peimanja commented 2 years ago

hey @Feriman22 , Are you trying to point to the exporter from Grafana as Prometheus data source? if yes, that's not possible. you have to have a Prometheus server running and collect metrics exported by this exporter. Then you can point to your prometheus server.

I'll have to look at the log format :)

peimanja commented 2 years ago

log.format flag is working as expected. you can pass --log.level=debug to actually see some details logs

./artifactory_exporter --artifactory.scrape-uri=https://**** --log.format=json --log.level=debug
{"caller":"artifactory_exporter.go:30","level":"info","msg":"Starting artifactory_exporter","ts":"2022-02-16T03:44:18.585Z","version":"(version=, branch=, revision=)"}
{"caller":"artifactory_exporter.go:31","context":"(go=go1.17.2, user=, date=)","level":"info","msg":"Build context","ts":"2022-02-16T03:44:18.586Z"}
{"address":":9531","caller":"artifactory_exporter.go:32","level":"info","msg":"Listening on address","ts":"2022-02-16T03:44:18.586Z"}
Feriman22 commented 2 years ago

Hi @peimanja

Thanks for your quick answer! You're right, that was the issue.

The weird thing is we cannot see all metrics what we should to see:

MicrosoftTeams-image (1)

Do you have any idea why?

Thanks!

peimanja commented 2 years ago

hey @Feriman22 enable the debug level logging and see if there is something going on there --log.level=debug

you can also check artifactory_exporter_total_api_errors and artifactory_exporter_json_parse_failures metrics to see if they are greater than 0. That indicates if there was an issue during the scrape and parsing of stats from Artifactory

also try scraping the exporter directly on the /metrics path and see what is exposed there

Feriman22 commented 2 years ago

Hi @peimanja

artifactory_exporter_json_parse_failures 0
artifactory_exporter_total_api_errors 1130

Here is the result with debug mode: issue

Error message:

level=debug ts=2022-02-18T09:01:18.505Z caller=utils.go:21 msg="Fetching http" path=https://ourafserver.com/ui/api/system/license
level=error ts=2022-02-18T09:01:18.510Z caller=system.go:72 msg="There was an issue when try to unmarshal licenseInfo respond"
peimanja commented 2 years ago

I think the issue is with your Artifactory URL. --artifactory.scrape-uri normally looks like https://ourafserver.com/artifactory not https://ourafserver.com/ui

Feriman22 commented 2 years ago

It should be /ui at the end, because we use Artifactory 7, where the URL has been changed from /artifactory to /ui

peimanja commented 2 years ago

It should be /ui at the end, because we use Artifactory 7, where the URL has been changed from /artifactory to /ui

we are also on 7+. Give the /artifactory path a try. for API it is still /artifactory. docs

You can also make API call to https://ourafserver.com/ui/api/system/license and see what response you get

Feriman22 commented 2 years ago

Hi @peimanja

You're right, the problem was with the URL, we have to use /artifactory instead of /ui

Many thanks for your help and have a nice week! :)

Feriman