Feature Requests: Please add some element ids to important metrics or export a json of alerts and properties

This issue has been tracked since 2022-02-11.

Since my company uses karma to show alerts(I have no access to prometheus/thanos in production) I've incorporated karma into my test automation CD/CI stack.

It works fine, but I have a few challenges:

  1. There are no ids on important elements, have to use range of properties which are very prone to changes
  2. we can only see the first page
  3. getting all values require complex xpath

The simplest would be to just export a json of alerts and their properties when giving a parameter, then I do not need
chrome,chromedriver and selenium in the container, just use a rest-api.

Under is an excerp of my current test using python and selenium:

karma-dashboard

totalAlerts = 0
alertNames = []
try:
    el = wd.find_element(By.XPATH, "//div[@class='text-center d-inline-block cursor-pointer navbar-brand m-0 components-navbar-button components-animation-flash-enter-done components-animation-flash-exit-done']")
    log.warning(f"total elements: {el.text}")
    totalAlerts = int(el.text)
except (NoSuchElementException, ElementNotInteractableException) as e:
    log.info("No warnings found all ok")
    sys.exit(0)
try:
    # we only get first page
    els = wd.find_elements(By.XPATH, "//span[@class='components-label-name' and contains(text(), 'alertname')]/following-sibling::span")
    log.info(f" we found {len(els)} alerts on first page they we can show")
    for el in els:
        log.info(f"alertname:{el.text}")
        alertNames.append(el.text)
except (NoSuchElementException, ElementNotInteractableException) as e:
    log.info("unable to parse alert components")
else:
    # we should fail if we find any alerts
    assert totalAlerts==0, f"no alerts but we got the following:{alertNames}"

output:

20220211131126|INFO|karma url: https://xxx.xxxxxxxx.xxx/?q=namespace%3D~.%2Bpayment.%2B
20220211131131|WARNING|total elements: 7
20220211131131|INFO| we found 6 alerts on first page they we can show
20220211131131|INFO|alertname:KubernetesPodNotHealthy
20220211131131|INFO|alertname:KubeContainerWaiting
20220211131131|INFO|alertname:KubernetesDeploymentReplicasMismatch
20220211131131|INFO|alertname:KubePodNotReady
20220211131132|INFO|alertname:KubeDeploymentReplicasMismatch
20220211131132|INFO|alertname:KubernetesDeploymentReplicasMismatch
prymitive wrote this answer on 2022-02-11

Karma is not the tool for CI, it's for humans to look at. The UI is provided as-is and will change frequently if needed.
You'll have much easier job if you'll get access to alertmanager APIs.
Karma is not the place to solve access issues at your company.

More Details About Repo
Owner Name prymitive
Repo Name karma
Full Name prymitive/karma
Language TypeScript
Created Date 2018-09-09
Updated Date 2023-03-17
Star Count 1921
Watcher Count 33
Fork Count 166
Issue Count 2

YOU MAY BE INTERESTED

Issue Title Created Date Updated Date