XCP-ng
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Prometheus SD through REST API

    Scheduled Pinned Locked Moved REST API
    10 Posts 2 Posters 1.7k Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • jmaraJ Offline
      jmara
      last edited by

      Hi,

      I was wondering if we could get a REST API Endpoint to discover vms via the prometheus build-in http_sd?

      As a starting point it would be nice the get the ips and pool association of vms through the /vms call so that it would be possible to write a wrapper script to match the http_sd format.

      Or is this possible and I haven't found the correct fields yet? 🙂

      Cheers,
      Jan

      1 Reply Last reply Reply Quote 1
      • olivierlambertO Offline
        olivierlambert Vates 🪐 Co-Founder CEO
        last edited by

        Hi,

        Can you be more specific? I never heard about http_sd 🤔

        jmaraJ 1 Reply Last reply Reply Quote 0
        • jmaraJ Offline
          jmara @olivierlambert
          last edited by

          @olivierlambert sure its a new service discovery plugin in the prometheus core which scrapes http endpoints:
          https://prometheus.io/docs/prometheus/latest/http_sd/

          It requires this json format:

          [
            {
              "targets": [ "<host>", ... ],
              "labels": {
                "<labelname>": "<labelvalue>", ...
              }
            },
            ...
          ]
          
          1 Reply Last reply Reply Quote 0
          • olivierlambertO Offline
            olivierlambert Vates 🪐 Co-Founder CEO
            last edited by

            @julien-f do you think it's something doable at some point?

            jmaraJ 1 Reply Last reply Reply Quote 0
            • jmaraJ Offline
              jmara @olivierlambert
              last edited by

              @olivierlambert As said, I would be a starting point if the fields of the /vms call will be extended to include ipaddesses, pool_name/id and maybe host_affinity

              1 Reply Last reply Reply Quote 0
              • olivierlambertO Offline
                olivierlambert Vates 🪐 Co-Founder CEO
                last edited by

                I think it's already the case if you add the value in the query string 🤔 (but I might be wrong). That's why I'm asking @julien-f ^^

                1 Reply Last reply Reply Quote 0
                • olivierlambertO Offline
                  olivierlambert Vates 🪐 Co-Founder CEO
                  last edited by olivierlambert

                  Here is what you asked:

                  curl -b authenticationToken=xxxbak 'http://xxxx/rest/v0/vms/?fields=name_label,%24pool,addresses,affinityHost'
                  

                  Which is returning this for me:

                    {
                      "name_label": "XOA 🎷",
                      "$pool": "xxxxxxxx-xxxx-xxxx-xxxx-2c519aa297e7",
                      "mainIpAddress": "192.168.x.x",
                      "addresses": {
                        "0/ipv4/0": "192.168.x.x",
                        "0/ipv6/0": "fe80::xxxx:xxxx:xxxx:xxxx"
                      },
                      "affinityHost": "xxxxxxxx-xxxx-xxxx-xxxx-0dc8858f6686",
                      "href": "/rest/v0/vms/xxxxxxxx-xxxx-xxxx-xxxx-a7a9306b347b"
                    }
                  

                  Note: affinityHost is missing if it's not set.

                  Note 2: you can use mainIpAddress field, which is the helper showing the first IP address visible from the tools.

                  jmaraJ 1 Reply Last reply Reply Quote 1
                  • olivierlambertO Offline
                    olivierlambert Vates 🪐 Co-Founder CEO
                    last edited by

                    Also, please keep us posted on this, I'm curious about the outcome and your use case 🙂 It's an interesting way of leveraging our API!

                    1 Reply Last reply Reply Quote 0
                    • jmaraJ Offline
                      jmara @olivierlambert
                      last edited by

                      @olivierlambert Uh very nice 🙂 now I got something to play with in the evening 🙂 I'll let you know once I've created a PoC

                      1 Reply Last reply Reply Quote 1
                      • olivierlambertO Offline
                        olivierlambert Vates 🪐 Co-Founder CEO
                        last edited by

                        👍

                        1 Reply Last reply Reply Quote 0
                        • julien-fJ julien-f moved this topic from Xen Orchestra on

                        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                        With your input, this post could be even better 💗

                        Register Login
                        • First post
                          Last post