Alertmanager `inhibit_rules` not working? - devops

I'm trying to configure something that seems very simple:
"If the datasource (prometheus) is down, don't spam alerts, and only notify that Prometheus is down"
Immediately I went to inhibit_rules, and after trying probably several hundred combinations I cannot make it work under any condition.
This is my config:
inhibit_rules:
- source_matchers:
- 'alertname = prometheus-up'
target_matchers:
- 'datasource = prometheus'
equal:
- 'datasource'
Now I've honestly tried any label combination I can think of, used different labels, no labels, no equal, NOTHING works, all alerts are fires whenever the datasource is down.
What am I missing here? the Prometheus/Alertmanager docs are terrible and provide no help, and no examples exist expect very simple use cases.

Related

Playwright: how to wait until there is no animation on the page?

I'm trying to figure out how to check whether the page has fully loaded in Playwright. await page.waitForLoadState('networkidle'); doesn't always work for me on Javascript-heavy sites. I've resorted to taking a screenshot base64, waiting 100 ms, taking a new screenshot, and comparing whether those are the same. However this doesn't seem ideal, is there any way to ask Playwright when the last animation frame was redrawn?
There are several options that may help you.
1. Solution 1:
First, you can maybe determine which element is loading last, and then go with
page.waitForSelector('yourselector')
or even wait for multiple selectors to appear
page.waitForSelector('yourselector1','yourselector2')
2. Solution 2
page.waitForLoadState('domcontentloaded')
Because
page.waitForLoadState('networkidle')
by default will wait for network event and if 0.5 seconds nothing is network trafficking it will say, I am no longer need to wait. And that is why you maybe have stohastic beh.
If the given solution doesn't work for you, you can try with locator.
page.locator(selector[, options])
It has multiple api like locator.isDisabled or locator.waitFor([options]) or locator.isVisible([options]) or locator.frameLocator(selector) ....... a lot more.
see the below link here:
https://playwright.dev/docs/api/class-locator

How to set a variable using geolocation.getCurrentPosition

This is related to this post, but different in that I am trying to understand why I cannot set an outside variable from inside of geolocation.getCurrentPosition
I can't seem to get any kind of return value from it, and I can't set a value from it. I can only access the position object from inside of it. I have tried passing in this.
I forked derek-朕會功夫's fiddle and modified it:
https://jsfiddle.net/TwoFistedJustice/c3qr29L7/1/
Here is another fiddle based on this post:
https://jsfiddle.net/TwoFistedJustice/yu8Lzjvx/4/
I'm very perplexed.
Could someone please help me to:
Understand what is going on behind the scenes to make it behave it
this way.
Understand how to set a variable in an outer scope from inside
getCurrentPosition().
I've been reading up on the call stack and callback queue. And I gather that the behavior that has been perplexing me has to do with how Javascript handles the various stacks and queues. This piece by Jake Archibald helps to clear it up, though it is bit much to absorb all at once.
If I add a setTimeout with any delay value, even 0, foo is USUALLY changed. With near-zero values, it varies a bit.
setTimeout(function(){
console.log('SetTimeout\n - Foo only changes if this goes AFTER the Promise\n foo:', foo)}
, 0);
This is a fiddle derived from the others that more clearly shows what is going on. https://jsfiddle.net/TwoFistedJustice/arkqb0x8/71/

Check element visibility that is visible for less than a second in Rails Capybara

I am trying to write an integration test in which I must check the visibility of an element on button click. The code works perfectly in one machine and failing in the other. The element is displayed until the data comes from the backend. So its visibility depends on the speed of the machine also. Is that the problem? This is the code:
assert page.has_css?('#my_element_id')
assert find('#my_element_id', visible: true)
But I am getting an error: expected false to be truthy.
Is there any other way to assert the visibility of the element?
You can also try:
assert find('#my_element_id').visible?
from: https://rubydoc.info/gems/capybara/0.4.0/Capybara/Element#visible%3F-instance_method
It does say however:
visible? ⇒ Boolean
Whether or not the element is visible. Not all drivers support CSS, so
the result may be inaccurate.
I assume you are talking about whether #my_element_id is visible.
EDIT:
If you are waiting for an element to be visible first before checking for the element with the id #my_element_id this posts might be helpful:
How to make Capybara check for visibility after some JS has run?
So you could wait for the backend data to come through then check visibility. If you are try to check that it is visible before that data, I am not quite sure, it seems like it would depend on the machine's internet connection to me.
Don’t use plain assert, use the assertions provided by Capybara which include retrying behavior
assert_css(‘#my_element_id’)
By default that would check only for visible elements, but if you’ve set Capybara.ignore_hidden_elements = false (don’t do that, really dont) then you would need to also pass the :visible option
Note: you may still have issues if it’s only visible for a very short time - in that case if you’re using Chrome you can set the network conditions to very slow in order to increase the time data takes to return

EKAlarms with relativeOffset

I'm currently trying to write a method to compare EKAlarms to one another. The problem with this is between absoluteDate and relativeOffset. Comparing two alarms each with an absoluteDate is easy, but if one or both have a relativeOffset, you need to know what event they're relatively offset from. As per the documentation,
relativeOffset: The offset from the start of an event, at which the alarm fires.
Yet, I see no documentation on setting the trigger for a relativeOffset alarm. Can anyone help me figure out what I'm missing? How can I compare two EKAlarms with relativeOffsets?
Thanks for the help!
As you rightly say:
if one or both have a relativeOffset, you need to know what event they're relatively offset from
Quite so. But how can you possibly not know that? EKAlarms do not float around loose, falling from the sky like snowflakes. If not attached to an EKCalendarItem, a relative EKAlarm is meaningless; there is nothing to compare. If it is attached to an EKCalendarItem, then you clearly know that fact - otherwise, where would you have gotten the alarm from??? Either you just created the alarm, and are about to attach it to an EKCalendarItem yourself, or you have started with the EKCalendarItem and have looked at its alarms property, in which case you also know the EKCalendarItem's startDate and can calculate from there.

Connections in mxgraph

I want to know how to avoid bidirectional connections. For example:
http://i.stack.imgur.com/4HR4H.png
Is there any way to do this?
I work with mxGraph, javascript.
EDIT: Sorry, maybe I didn’t explain well, I mean if we have two cells (a---> b) cannot be (a <--- b) this may be detected in real time.
Remove startArrow=classic from the style of the edge.
you can check out this example Validation - Using multiplicities for automatically validating a graph.
mxMultiplicity defines invalid connections along with the error messages that they produce.

Resources