05 Apr 2021 02:07 PM - last edited on 01 Jul 2021 06:42 AM by MaciejNeumann
This command works great, and I get CPU stats for my server.
I am now trying to dress that up. How can I limit or add fields in the response?
QUESTION 1 - If I try limiting the fields by removing one, it errors out. What am I doing wrong, or is this not allowed?
QUESTION 2 - What if I want to have the server tag name in the CSV output? Is that possible. I can always add it after the API query if I have to.
I'm really trying to dress up the CSV extract to feed into a statistical engine like R.
Any advice is appreciated.
Lou (API V2 Newbie)
Solved! Go to Solution.
Okay, partial success. I can get the server name in the names transformation. Yea!!!
oi @louis_gallo about question one something isn't right because "field=" is not included directly in an Api v2 call like you are using "api/v2/metrics/query?"
you can find "field=" in this kind of api:
Plus the api call in question 1 seems to contain different error since you have at least two (?):
If you go on more detail maybe we can help you out 🙂
Let us know how it went!
Question 1 - the "fields" parameter is not valid for the /metrics/query API endpoint. This is why it errors out. The "fields" parameter can be used instead with the /metrics endpoint which is used to retrieve information about the metric definition itslef. You can use this endpoint for example to find out what dimensions can a metric be split by (this is done by adding fields=+dimensionDefinitions).
Question2 - names of entities and dimensions returned by the /metrics/query API calls can be added in using the :names: transformation. Tags cannot be added as dimensions, but they can be used for filtering out entities that are returned in the result set. You can do that within the entitySelector parameter (e.g. entitySelector=type(service),tag(Environment:Staging) for including only services tagged with Environment=Staging)
I hope this helps.