jangraefen / hcloud-pricing-exporter

A prometheus exporter for the current pricing and costs of your HCloud account
MIT License
56 stars 8 forks source link

Pagination limit for fetcher? #124

Closed smarakdas314 closed 10 months ago

smarakdas314 commented 10 months ago

Hi my project has more cloud servers in environment, but it seems exporter is limited by default, fetching only 25 results or it's some dependancy on another lib like hcloud as I could not find '25' in this repo?

How can I overcome this limitation in the exporter?

I saw in code there is:

import
"github.com/hetznercloud/hcloud-go/hcloud"

...
client.Server.List(ctx, hcloud.ServerListOpts{})

Result:

curl localhost:8080/metrics | grep server_monthly | grep -v -e "# HELP" -e "# TYPE" | wc -l
25
curl https://api.hetzner.cloud/v1/servers
  "meta": {
    "pagination": {
      "page": 1,
      "per_page": 25,
      "previous_page": null,
      "next_page": 2,
      "last_page": 4,
      "total_entries": 100
    }
  }

-- (edit)

https://github.com/hetznercloud/hcloud-go/

 import (
-  "github.com/hetznercloud/hcloud-go/hcloud"
+  "github.com/hetznercloud/hcloud-go/v2/hcloud"
 )

v1 is supported until September 1st 2023 with new features, so I guess it will need some updating to v2 in the future as well..

jangraefen commented 10 months ago

Hello @smarakdas314,

thank you for letting me know. To be honest, I never had more resources then 25 of any given kind, so I was completly unaware. I am working on a fix right now. I will also update hcloud-go.

With kind regards

jangraefen commented 10 months ago

Hello @smarakdas314,

just released v0.8.0, containing a fix. Thanks again for reporting the problem.

With kind regards

smarakdas314 commented 10 months ago

@jangraefen kudos for quick reaction, you made me happy. Hats to you! ❤️ 🎩

I've also published my python script on github, maybe someone will find it useful on the internet, and can re-use it to their liking, and understand more easily how it works.

https://github.com/smarakdas314/hcloud-pricing-exporter-python/tree/main