On Tue, May 11, 2021 at 10:58 AM Hello World <[email protected]>
wrote:

> Hi Matt,
> Thanks for the response.
> Is there a way to select all the values without any aggregation?
>
> Similar to what we do in database applications,
> Movies
> Name             Director                  Year                 IMDB_Rating
>    X1                     Y1                      2020
>    9.1
>    X2                     Y2                      2021
>    8.4
>    X3                     Y3                      2019
>    7.6
>
> Now, an API is only interested in the Names and Years of all the titles,
> so, we just want to select Name and Year from the above table, and the
> result should look something like this
> Name             Year
>    X1               2020
>    X2               2021
>    X3               2019
>

Given this example, *sum by (Name, Year) *will give you exactly what you
want.
You can't drop labels from a tsdb query without doing aggregation, because
the query would lose information.
In the above example, what would happen if a movie had two directors?

The Prometheus TSDB is not a general purpose database like MySQL, it is
specifically designed around storing numerical values with labels.
If all you care about is purely the values of the Name and Year labels,
then you should use the labels and values APIs.

<prom host:port>/api/v1/label/Name/values
<prom host:port>/api/v1/label/Year/values


>
> is this possible with Prometheus? This would be very useful as we would
> transfer only the required fields over the network.
> On Tuesday, 11 May 2021 at 01:03:22 UTC+5:30 [email protected] wrote:
>
>> You need to aggregate the data.  Most likely what you are looking for
>> (given your example) is
>>
>> sum by (namespace, svc_name) up
>>
>> If sum is not the right aggregation, you can use any of the aggregation
>> operators
>> <https://urldefense.proofpoint.com/v2/url?u=https-3A__prometheus.io_docs_prometheus_latest_querying_operators_-23aggregation-2Doperators&d=DwMFaQ&c=o2Rg2hCP31Es1DdrOYH75Q&r=j64P62uxP3fuCGhy7QIFzHc5tMo0hYAmg9RiTtOmVJM&m=YL_QmwMBDx3VCzQV6tThPLsdVlG7DzNluxpCos3rSGs&s=mh5jEaIwTYTB1hAF56R5n_rFDB3G2MoIDyOY4mrSsH4&e=>
>> .
>>
>> On Mon, May 10, 2021 at 9:09 AM Hello World <[email protected]> wrote:
>>
>>> This is not filtering the labels by values here I only want to select
>>> couple of labels in the results instead of getting all the labels over the
>>> wire.
>>> Also, I'm not using this for visualization, I'm trying to write a
>>> backend API which fetches the data from prometheus and runs some business
>>> logic on the data.
>>>
>>> Thanks for your time.
>>>
>>> On Monday, 10 May 2021 at 12:38:50 UTC+5:30 Hello World wrote:
>>>
>>>> Hi All,
>>>>
>>>> Let us assume that we have some metrics like this,
>>>> up {instance="instance1", job="job1", namespace="namespace1",
>>>> svc_name="first_service"}
>>>> up {instance="instance1", job="job2", namespace="namespace2",
>>>> svc_name="second_service"}
>>>>
>>>> is there a way to select specific labels from the server instead of
>>>> getting all the labels in the result? like the svc_name, namespace.etc
>>>> something like this,
>>>>
>>>> up{namespace="namespace1", svc_name="first_service"}
>>>> up{namespace="namespace2", svc_name="second_service"}
>>>>
>>>> This is like selecting a couple of columns from a table containing 20
>>>> columns.
>>>>
>>>> Thanks.
>>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Prometheus Users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/prometheus-users/5494d002-4f35-4799-971a-cb1e12a281c5n%40googlegroups.com
>>> <https://urldefense.proofpoint.com/v2/url?u=https-3A__groups.google.com_d_msgid_prometheus-2Dusers_5494d002-2D4f35-2D4799-2D971a-2Dcb1e12a281c5n-2540googlegroups.com-3Futm-5Fmedium-3Demail-26utm-5Fsource-3Dfooter&d=DwMFaQ&c=o2Rg2hCP31Es1DdrOYH75Q&r=j64P62uxP3fuCGhy7QIFzHc5tMo0hYAmg9RiTtOmVJM&m=ho-wnkrBA9hHu9LfubqIOFXLYx6Cbe1NsbWlSftkKZ4&s=HpAyJ3mALMHBQT2hOjrU55NzMBH1bljEEQk7nLZxDvY&e=>
>>> .
>>>
>>
>> This e-mail and all information in, attached to, or linked via this
>> e-mail (together the ‘e-mail’) is confidential and may be legally
>> privileged. It is intended solely for the intended addressee(s). Access to,
>> or any onward transmission, of this e-mail by any other person is not
>> authorised. If you are not the intended recipient, you are requested to
>> immediately alert the sender of this e-mail and to immediately delete this
>> e-mail. Any disclosure in any form of all or part of this e-mail, or of any
>> the parties to it, including any copying, distribution or any action taken
>> or omitted to be taken in reliance on it, is prohibited and may be
>> unlawful.
>>
>>
>> This e-mail is not, and is not intended to be, and should not be
>> construed as being, (a) any offer, solicitation, or promotion of any kind;
>> (b) the basis of any investment or other decision(s);  (c) any
>> recommendation to buy, sell or transact in any manner any good(s),
>> product(s) or service(s), nor engage in any investment(s) or other
>> transaction(s) or activities;  or (d) the provision of, or related to, any
>> advisory service(s) or activities, including regarding any investment, tax,
>> legal, financial, accounting, consulting or any other related service(s).
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Prometheus Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/prometheus-users/63ed1280-18df-4fb7-a170-152a2469ed26n%40googlegroups.com
> <https://urldefense.proofpoint.com/v2/url?u=https-3A__groups.google.com_d_msgid_prometheus-2Dusers_63ed1280-2D18df-2D4fb7-2Da170-2D152a2469ed26n-2540googlegroups.com-3Futm-5Fmedium-3Demail-26utm-5Fsource-3Dfooter&d=DwMFaQ&c=o2Rg2hCP31Es1DdrOYH75Q&r=j64P62uxP3fuCGhy7QIFzHc5tMo0hYAmg9RiTtOmVJM&m=YL_QmwMBDx3VCzQV6tThPLsdVlG7DzNluxpCos3rSGs&s=RCMsDkFKMAC0Qrl0nS-pK3MBCnYJ52vnMyoQaxCUVlQ&e=>
> .
>

-- 


This e-mail and all information in, attached to, or linked via this 
e-mail (together the ‘e-mail’) is confidential and may be legally 
privileged. It is intended solely for the intended addressee(s). Access to, 
or any onward transmission, of this e-mail by any other person is not 
authorised. If you are not the intended recipient, you are requested to 
immediately alert the sender of this e-mail and to immediately delete this 
e-mail. Any disclosure in any form of all or part of this e-mail, or of any 
the parties to it, including any copying, distribution or any action taken 
or omitted to be taken in reliance on it, is prohibited and may be 
unlawful. 




This e-mail is not, and is not intended to be, and should 
not be construed as being, (a) any offer, solicitation, or promotion of any 
kind; (b) the basis of any investment or other decision(s);  (c) any 
recommendation to buy, sell or transact in any manner any good(s), 
product(s) or service(s), nor engage in any investment(s) or other 
transaction(s) or activities;  or (d) the provision of, or related to, any 
advisory service(s) or activities, including regarding any investment, tax, 
legal, financial, accounting, consulting or any other related service(s).

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/CAJsAWL5DfA2b3WHuh%2BgkQ6QwEWSRn3_iOdH3rS-E4pGpwQXF_Q%40mail.gmail.com.

Reply via email to