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

How to use model.Value? #254

Open
JackGzj opened this issue Sep 1, 2020 · 2 comments
Open

How to use model.Value? #254

JackGzj opened this issue Sep 1, 2020 · 2 comments

Comments

@JackGzj
Copy link

JackGzj commented Sep 1, 2020

I am using the Go client for Prometheus, but I wonder how to parse the response data in model.Value (including Vector and Matrix). I have checked the source code, only to find the String() method to get the Vector like {pod="test-001-deployment-896b6d55b-bs586"} => 0.06435052290435223 @[1598949467.625] {pod="test-003-deployment-665d48fb7f-dlxfb"} => 0.03620828100637146 @[1598949467.625]. So, how can I use the model data gracefully?

@brian-brazil
Copy link
Contributor

It makes more sense to ask questions like this on the prometheus-users mailing list rather than in a GitHub issue. On the mailing list, more people are available to potentially respond to your question, and the whole community can benefit from the answers provided.

@isabelgiang
Copy link

isabelgiang commented Sep 20, 2021

For anyone else stumbling upon this issue, model.Value is an interface.

If you're in the same situation that I am in, and you're trying to mock an API call from Prometheus that returns model.Value, you can use something like this:

model.Value(
    model.Vector{
        ...
    }
)


You're asking the Go compiler to treat this concrete type as the interface it implements.

Another example here

alanprot pushed a commit to alanprot/common that referenced this issue Mar 15, 2023
httpgrpc/server: Update NewClient to not use WithBalancerName
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

3 participants