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

Add metrics for workers. #21

Merged
merged 1 commit into from
Sep 28, 2021
Merged

Add metrics for workers. #21

merged 1 commit into from
Sep 28, 2021

Conversation

pvdvreede
Copy link
Contributor

This actions issue #17 .

The functionality is there and will introspect the accounts the CF TOKEN has access to and then get worker metrics from there.

Not sure if this is the wanted behaviour as the token will need extra permissions (which i will update the readme with once things are looking good :) ).

Should I add a CF_ACCOUNTS env var to limit accounts to check? If the var does not exists it will not get any worker metrics, so its backward compatible?

@pvdvreede pvdvreede marked this pull request as ready for review June 28, 2021 04:28
@martinhaus
Copy link
Member

@pvdvreede thanks for the PR. We don't have CF workers in our setup so it's hard for me to actually test this out.
I don't get any errors when running the code from your PR on my accounts with them having no workers. I assume it's compatible for users which don't use this functionality so I'm going to merge this. The code looks good. Thanks for the PR again!

@martinhaus
Copy link
Member

@pvdvreede Oh, and more thing. Could you update the readme to reflect the changes you've made. Especially the list of metrics.

@pvdvreede
Copy link
Contributor Author

yep, will update things, clean it up and rebase soon, thanks!

@nouvellonsteph
Copy link

nouvellonsteph commented Aug 5, 2021

Hey @pvdvreede!

Thanks for your contribution. I was indeed able to fetch the correct data from the several accounts I'm having attached to the token I did use to test this one. The result is the following:

# TYPE cloudflare_worker_errors_count counter
cloudflare_worker_errors_count{script_name="6hourfailure"} 0
cloudflare_worker_errors_count{script_name="billowing-truth-a2bd"} 0
cloudflare_worker_errors_count{script_name="blue-scene-f745"} 0
cloudflare_worker_errors_count{script_name="calm-frost-b418"} 0
cloudflare_worker_errors_count{script_name="cf-china-icp"} 0
cloudflare_worker_errors_count{script_name="cpu-time-oscillator"} 0
cloudflare_worker_errors_count{script_name="dawn-poetry-0f9b"} 0
cloudflare_worker_errors_count{script_name="elastic-helper"} 0
cloudflare_worker_errors_count{script_name="falling-limit-3dcb"} 0
cloudflare_worker_errors_count{script_name="jolly-mud-42d0"} 0
cloudflare_worker_errors_count{script_name="muddy-forest-9137"} 0
cloudflare_worker_errors_count{script_name="patient-heart-c7fc"} 0
cloudflare_worker_errors_count{script_name="patient-thunder-bbd7"} 0
cloudflare_worker_errors_count{script_name="patient-unit-e919"} 0
cloudflare_worker_errors_count{script_name="random-failing-check"} 0
cloudflare_worker_errors_count{script_name="raspy-brook-2546"} 0
cloudflare_worker_errors_count{script_name="restless-cherry-2be0"} 0
cloudflare_worker_errors_count{script_name="royal-glitter-793b"} 0
cloudflare_worker_errors_count{script_name="sgw_v7-317-g2e64e86"} 0
cloudflare_worker_errors_count{script_name="slow-response"} 0
cloudflare_worker_errors_count{script_name="sparkling-sky-4207"} 0
cloudflare_worker_errors_count{script_name="sweet-wildflower-6fe5"} 0
cloudflare_worker_errors_count{script_name="sweet-wind-e828"} 0
cloudflare_worker_errors_count{script_name="test-data-egress"} 0
cloudflare_worker_errors_count{script_name="young-resonance-a7e4"} 0
# HELP cloudflare_worker_requests_count Number of requests sent to worker by script name
# TYPE cloudflare_worker_requests_count counter
cloudflare_worker_requests_count{script_name="6hourfailure"} 6199
cloudflare_worker_requests_count{script_name="billowing-truth-a2bd"} 4
cloudflare_worker_requests_count{script_name="blue-scene-f745"} 4
cloudflare_worker_requests_count{script_name="calm-frost-b418"} 4
cloudflare_worker_requests_count{script_name="cf-china-icp"} 1
cloudflare_worker_requests_count{script_name="cpu-time-oscillator"} 1
cloudflare_worker_requests_count{script_name="dawn-poetry-0f9b"} 156
cloudflare_worker_requests_count{script_name="elastic-helper"} 8
cloudflare_worker_requests_count{script_name="falling-limit-3dcb"} 4
cloudflare_worker_requests_count{script_name="jolly-mud-42d0"} 4
cloudflare_worker_requests_count{script_name="muddy-forest-9137"} 4
cloudflare_worker_requests_count{script_name="patient-heart-c7fc"} 4
cloudflare_worker_requests_count{script_name="patient-thunder-bbd7"} 4
cloudflare_worker_requests_count{script_name="patient-unit-e919"} 6
cloudflare_worker_requests_count{script_name="random-failing-check"} 24
cloudflare_worker_requests_count{script_name="raspy-brook-2546"} 4
cloudflare_worker_requests_count{script_name="restless-cherry-2be0"} 6
cloudflare_worker_requests_count{script_name="royal-glitter-793b"} 4
cloudflare_worker_requests_count{script_name="sgw_v7-317-g2e64e86"} 1321
cloudflare_worker_requests_count{script_name="slow-response"} 24
cloudflare_worker_requests_count{script_name="sparkling-sky-4207"} 4
cloudflare_worker_requests_count{script_name="sweet-wildflower-6fe5"} 4
cloudflare_worker_requests_count{script_name="sweet-wind-e828"} 4
cloudflare_worker_requests_count{script_name="test-data-egress"} 4
cloudflare_worker_requests_count{script_name="young-resonance-a7e4"} 4

As @martinhaus mentioned, it would be nice to update the readme by adding the new counters you've added.

Good job!

@m0ar
Copy link
Contributor

m0ar commented Sep 3, 2021

Beat me to it @pvdvreede ! This is super useful 🧁

I just tested to build and run this container, but I see nothing related to workers in localhost:8080/metrics and the docker log repeats this line:

time="2021-09-03 14:38:26" level=error msg="graphql: zone '277eecbb012f75864b1362e4f4c860d4' does not have access to the path"

I have tried with just the CF_API_TOKEN and both CF_API_KEY+CF_API_EMAIL.
Am I missing something? 🤔

EDIT: actually, nothing related to Cloudflare at all, am I looking at the metrics for the exporter container itself?

@m0ar
Copy link
Contributor

m0ar commented Sep 22, 2021

Seems to work only when I use the Global API key, not at all when I use a token scoped over Account Analytics, Analytics and Zone. Not that it has anything to do with this particular PR, but it is indeed confusing. Also not very principle of least privilege.

@nouvellonsteph could you elaborate on how you setup the correct token?

@m0ar m0ar mentioned this pull request Sep 28, 2021
@martinhaus martinhaus merged commit 4b21a61 into lablabs:master Sep 28, 2021
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

Successfully merging this pull request may close these issues.

4 participants