Thanks alot Ben and Brian! really appreciated, finally can reduce the 
cardinality a bit :D 
On Tuesday, June 13, 2023 at 3:38:29 PM UTC+1 Ben Kochie wrote:

> Prometheus Drop and Keep are exclusive. So they work against all metrics 
> that match, or all metrics that don't.
>
> What we're doing is taking a metrics like this:
>
> mysql_info_schema_table_size{instance_name="primary-00"}
> mysql_info_schema_table_size{instance_name="secondary-00"}
>
> Phase 1 does this:
>
> mysql_info_schema_table_size{instance_name="primary-00",__tmp_keep="true"}
> mysql_info_schema_table_size{instance_name="secondary-00"}
>
> Second phase drops where `__tmp_keep` is ""
>
> So all you are left with is 
>
> mysql_info_schema_table_size{instance_name="primary-00"}
>
> (Brian's version does the labeldrop automatically)
>
> On Tue, Jun 13, 2023 at 4:33 PM pandrian <[email protected]> 
> wrote:
>
>> Oh wow! thanks a bunch guys that works!
>>
>> Any chance you could explain step by step how does this work? i lost you 
>> on the drop action, if keep label is the set of instance and table then how 
>> does this work? im confused :D 
>>
>>
>> On Tuesday, June 13, 2023 at 2:38:15 PM UTC+1 Brian Candler wrote:
>>
>>> Or use "__tmp_keep" as the temporary label, then you shouldn't need the 
>>> labeldrop step.
>>>
>>> On Tuesday, 13 June 2023 at 14:01:16 UTC+1 Ben Kochie wrote:
>>>
>>>> Negative lookahead regexp syntax is not supported.
>>>>
>>>> https://github.com/google/re2/wiki/Syntax
>>>>
>>>> What you can do is use use a temporary relabel to mark metrics as 
>>>> "keep".
>>>>
>>>> Something like this:
>>>>    
>>>> metric_relabel_configs:
>>>>   # Drop the specific metric from all instances except primary
>>>>   - source_labels: [instance_name, __name__]
>>>>     regex: 'primary-00;mysql_info_schema_table_size'
>>>>     replacement: 'true'
>>>>     target_label: keep
>>>>   - source_labels: [__name__,keep]
>>>>     regex: 'mysql_info_schema_table_size;'
>>>>     action: drop
>>>>   - regex: keep
>>>>     action: labeldrop
>>>>
>>>> On Tue, Jun 13, 2023 at 2:51 PM pandrian <[email protected]> 
>>>> wrote:
>>>>
>>>>> Hey guys im trying to basically drop a specific metric from a job that 
>>>>> has a couple of instances but keep it only for one instance is this 
>>>>> possible? 
>>>>>
>>>>> i tried something like this but its not working. 
>>>>>
>>>>>       metric_relabel_configs:
>>>>>         # Drop the specific metric from all instances except primary
>>>>>         - source_labels: [instance_name, __name__]
>>>>>           regex: '!^primary-00,mysql_info_schema_table_size'
>>>>>           action: drop
>>>>>
>>>>>
>>>>> -- 
>>>>> 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/46d8e23e-17b0-4f63-96cc-b8c5be3a2251n%40googlegroups.com
>>>>>  
>>>>> <https://groups.google.com/d/msgid/prometheus-users/46d8e23e-17b0-4f63-96cc-b8c5be3a2251n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>>
>>>> -- 
>> 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/2a32d9c0-f8ce-474e-978a-1fb072f303f8n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/prometheus-users/2a32d9c0-f8ce-474e-978a-1fb072f303f8n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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/7cbf9791-ab23-4103-865d-9c57233bad07n%40googlegroups.com.

Reply via email to