Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Onboard Synthetics Monitor Status rule type with FAAD #186214

Merged
merged 5 commits into from
Jun 20, 2024

Conversation

doakalexi
Copy link
Contributor

@doakalexi doakalexi commented Jun 13, 2024

Towards: #169867

This PR onboards the Synthetics Monitor Status rule type with FAAD.

To verify

I can't get the rule to alert, so I modified the status check to report the monitor as down. If you know of an easier way pls let me know 🙂

  1. Create a monitor, by default creating a monitor creates a rule.
  2. Click on the monitor and grab the id and locationId from the url
  3. Go to the status check code and replace the object that is returned with the following using the id and locationId you got from the monitor.
{
    up: 0,
    down: 1,
    pending: 0,
    upConfigs: {},
    pendingConfigs: {},
    downConfigs: {
      '${id}-${locationId}': {
        configId: '${id}',
        monitorQueryId: '${id}',
        status: 'down',
        locationId: '${locationId}',
        ping: {
          '@timestamp': new Date().toISOString(),
          state: {
            id: 'test-state',
          },
          monitor: {
            name: 'test-monitor',
          },
          observer: {
            name: 'test-monitor',
          },
        } as any,
        timestamp: new Date().toISOString(),
      },
    },
    enabledMonitorQueryIds: ['${id}'],
  };
  1. Your rule should create an alert and should saved it in .internal.alerts-observability.uptime.alerts-default-000001
    Example:
GET .internal.alerts-*/_search
  1. Recover repeating step 3 using
{
    up: 1,
    down: 0,
    pending: 0,
    downConfigs: {},
    pendingConfigs: {},
    upConfigs: {
      '${id}-${locationId}': {
        configId: '${id}',
        monitorQueryId: '${id}',
        status: 'down',
        locationId: '${locationId}',
        ping: {
          '@timestamp': new Date().toISOString(),
          state: {
            id: 'test-state',
          },
          monitor: {
            name: 'test-monitor',
          },
          observer: {
            name: 'test-monitor',
          },
        } as any,
        timestamp: new Date().toISOString(),
      },
    },
    enabledMonitorQueryIds: ['${id}'],
  };
  1. The alert should be recovered and the AAD in the above index should be updated kibana.alert.status: recovered.

@doakalexi
Copy link
Contributor Author

/ci

@doakalexi doakalexi changed the title Updating monitor status rule to use faad Onboard Synthertics Monitor Status rule type with FAAD Jun 13, 2024
@doakalexi doakalexi changed the title Onboard Synthertics Monitor Status rule type with FAAD Onboard Synthetics Monitor Status rule type with FAAD Jun 13, 2024
@doakalexi doakalexi requested review from a team, pmuellr and umbopepato June 13, 2024 20:56
@doakalexi doakalexi added Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) release_note:skip Skip the PR/issue when compiling release notes v8.15.0 labels Jun 13, 2024
@doakalexi doakalexi marked this pull request as ready for review June 13, 2024 20:59
@doakalexi doakalexi requested a review from a team as a code owner June 13, 2024 20:59
@elasticmachine
Copy link
Contributor

Pinging @elastic/response-ops (Team:ResponseOps)

@botelastic botelastic bot added ci:project-deploy-observability Create an Observability project Team:obs-ux-infra_services Observability Infrastructure & Services User Experience Team labels Jun 13, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ux-infra_services-team (Team:obs-ux-infra_services)

Copy link
Member

@umbopepato umbopepato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as expected, LGTM! 👍

Screenshot 2024-06-18 at 15 12 08

👇

Screenshot 2024-06-18 at 15 22 56

Copy link
Member

@pmuellr pmuellr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code LGTM, but unable to test locally. I got stopped at trying to add an agent, that wanted me to install a fleet server. Looks like it wants something (Fleet server) installed, which requires Elastic Agent to be installed - I gave up after that.

LMK if there's an easy way to test locally, or maybe it's possible to point to a Fleet server in the cloud or something?

@pmuellr
Copy link
Member

pmuellr commented Jun 18, 2024

I was holding Kibana wrong, Alexi showed me the correct way, and was able to verify with the instructions above. Hint - go to Synthetics from the main left nav, not from within the o11y app, as that led me astray, trying to set up Fleet before I could do anything else.

@doakalexi doakalexi enabled auto-merge (squash) June 20, 2024 12:19
Copy link
Contributor

@crespocarlos crespocarlos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM.

@kibana-ci
Copy link
Collaborator

kibana-ci commented Jun 20, 2024

💚 Build Succeeded

Metrics [docs]

Unknown metric groups

References to deprecated APIs

id before after diff
synthetics 24 22 -2

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@doakalexi doakalexi merged commit 0468b8f into elastic:main Jun 20, 2024
24 checks passed
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Jun 20, 2024
bhapas pushed a commit to bhapas/kibana that referenced this pull request Jun 24, 2024
Towards: elastic#169867

This PR onboards the Synthetics Monitor Status rule type with FAAD.

### To verify
I can't get the rule to alert, so I modified the status check to report
the monitor as down. If you know of an easier way pls let me know 🙂

1. Create a [monitor](http://localhost:5601/app/synthetics/monitors), by
default creating a monitor creates a rule.
2. Click on the monitor and grab the id and locationId from the url
3. Go to [the status check
code](https://github.com/elastic/kibana/blob/main/x-pack/plugins/observability_solution/synthetics/server/queries/query_monitor_status.ts#L208)
and replace the object that is returned with the following using the id
and locationId you got from the monitor.
```
{
    up: 0,
    down: 1,
    pending: 0,
    upConfigs: {},
    pendingConfigs: {},
    downConfigs: {
      '${id}-${locationId}': {
        configId: '${id}',
        monitorQueryId: '${id}',
        status: 'down',
        locationId: '${locationId}',
        ping: {
          '@timestamp': new Date().toISOString(),
          state: {
            id: 'test-state',
          },
          monitor: {
            name: 'test-monitor',
          },
          observer: {
            name: 'test-monitor',
          },
        } as any,
        timestamp: new Date().toISOString(),
      },
    },
    enabledMonitorQueryIds: ['${id}'],
  };
```
5. Your rule should create an alert and should saved it in
`.internal.alerts-observability.uptime.alerts-default-000001`
Example:
```
GET .internal.alerts-*/_search
```
6. Recover repeating step 3 using
```
{
    up: 1,
    down: 0,
    pending: 0,
    downConfigs: {},
    pendingConfigs: {},
    upConfigs: {
      '${id}-${locationId}': {
        configId: '${id}',
        monitorQueryId: '${id}',
        status: 'down',
        locationId: '${locationId}',
        ping: {
          '@timestamp': new Date().toISOString(),
          state: {
            id: 'test-state',
          },
          monitor: {
            name: 'test-monitor',
          },
          observer: {
            name: 'test-monitor',
          },
        } as any,
        timestamp: new Date().toISOString(),
      },
    },
    enabledMonitorQueryIds: ['${id}'],
  };
```
8. The alert should be recovered and the AAD in the above index should
be updated `kibana.alert.status: recovered`.
doakalexi added a commit to doakalexi/kibana that referenced this pull request Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apm:review backport:skip This commit does not require backporting ci:project-deploy-observability Create an Observability project release_note:skip Skip the PR/issue when compiling release notes Team:obs-ux-infra_services Observability Infrastructure & Services User Experience Team Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) v8.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants