[APM] Alert counts in Service groups#144484
Conversation
118eac2 to
cc6719e
Compare
|
Pinging @elastic/apm-ui (Team:APM) |
x-pack/plugins/apm/public/components/app/service_groups/service_group_save/create_button.tsx
Outdated
Show resolved
Hide resolved
dgieselaar
left a comment
There was a problem hiding this comment.
@ogupte can you add API tests?
There was a problem hiding this comment.
Is it really needed? Can we just render the translation if serviceCountis defined?
There was a problem hiding this comment.
This was in place for 8.5 in order to avoid a jump in height after service counts were loaded. But we may want to re-think the loading state for these cards of service groups.
...plugins/apm/public/components/app/service_groups/service_groups_list/service_groups_list.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/apm/server/routes/service_groups/get_services_counts.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/apm/server/routes/service_groups/get_service_group_alerts.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/apm/server/routes/service_groups/get_service_group_alerts.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/apm/server/routes/service_groups/get_apm_alerts_client.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/apm/server/routes/service_groups/get_apm_alerts_client.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/apm/server/routes/service_groups/get_service_group_alerts.ts
Outdated
Show resolved
Hide resolved
fkanout
left a comment
There was a problem hiding this comment.
Actionable Observability changes LGTM
x-pack/plugins/apm/server/routes/service_groups/get_service_group_alerts.ts
Outdated
Show resolved
Hide resolved
…p-level mapping - adds click thru for alerts count badge to observability alerts paged filtered by service group kuery
| const start = Date.now() - 24 * 60 * 60 * 1000; | ||
| const end = Date.now(); | ||
|
|
||
| async function callApi() { |
There was a problem hiding this comment.
| async function callApi() { | |
| async function getServiceGroupCounts() { |
| type: string; | ||
| }>; | ||
|
|
||
| async function deleteServiceGroups() { |
There was a problem hiding this comment.
| async function deleteServiceGroups() { | |
| async function deleteAllServiceGroups() { |
| const response = await supertest | ||
| .get('/api/saved_objects/_find?type=apm-service-group') | ||
| .set('kbn-xsrf', 'true'); | ||
| const savedObjects: SavedObjectsFindResults = response.body.saved_objects; | ||
| const bulkDeleteBody = savedObjects.map(({ id, type }) => ({ id, type })); | ||
| return supertest | ||
| .post(`/api/saved_objects/_bulk_delete?force=true`) | ||
| .set('kbn-xsrf', 'true') | ||
| .send(bulkDeleteBody); |
There was a problem hiding this comment.
Unless it is much slower, we should use our own APIs.
To retrieve all service groups:
GET /internal/apm/service-groups
Then, to delete a service group:
DELETE /internal/apm/service-group
There was a problem hiding this comment.
Yes, makes sense, I used our own for the e2e tests
| let synthbeansServiceGroupId: string; | ||
| let opbeansServiceGroupId: string; | ||
| before(async () => { | ||
| const synthServices = [ | ||
| apm | ||
| .service({ name: 'synth-go', environment: 'testing', agentName: 'go' }) | ||
| .instance('instance-1'), | ||
| apm | ||
| .service({ name: 'synth-java', environment: 'testing', agentName: 'java' }) | ||
| .instance('instance-2'), | ||
| apm | ||
| .service({ name: 'opbeans-node', environment: 'testing', agentName: 'nodejs' }) | ||
| .instance('instance-3'), | ||
| ]; | ||
|
|
||
| const [, { body: synthbeansServiceGroup }, { body: opbeansServiceGroup }] = await Promise.all( | ||
| [ | ||
| synthtraceEsClient.index( | ||
| synthServices.map((service) => | ||
| timerange(start, end) | ||
| .interval('5m') | ||
| .rate(1) | ||
| .generator((timestamp) => | ||
| service | ||
| .transaction({ | ||
| transactionName: 'GET /api/product/list', | ||
| transactionType: 'request', | ||
| }) | ||
| .duration(2000) | ||
| .timestamp(timestamp) | ||
| .children( | ||
| service | ||
| .span({ | ||
| spanName: '/_search', | ||
| spanType: 'db', | ||
| spanSubtype: 'elasticsearch', | ||
| }) | ||
| .destination('elasticsearch') | ||
| .duration(100) | ||
| .success() | ||
| .timestamp(timestamp), | ||
| service | ||
| .span({ | ||
| spanName: '/_search', | ||
| spanType: 'db', | ||
| spanSubtype: 'elasticsearch', | ||
| }) | ||
| .destination('elasticsearch') | ||
| .duration(300) | ||
| .success() | ||
| .timestamp(timestamp) | ||
| ) | ||
| .errors( | ||
| service.error({ message: 'error 1', type: 'foo' }).timestamp(timestamp), | ||
| service.error({ message: 'error 2', type: 'foo' }).timestamp(timestamp), | ||
| service.error({ message: 'error 3', type: 'bar' }).timestamp(timestamp) | ||
| ) | ||
| ) | ||
| ) | ||
| ), | ||
| saveServiceGroup({ | ||
| groupName: 'synthbeans', | ||
| kuery: 'service.name: synth*', | ||
| }), | ||
| saveServiceGroup({ | ||
| groupName: 'opbeans', | ||
| kuery: 'service.name: opbeans*', | ||
| }), | ||
| ] | ||
| ); | ||
| synthbeansServiceGroupId = synthbeansServiceGroup.id; | ||
| opbeansServiceGroupId = opbeansServiceGroup.id; | ||
| }); |
There was a problem hiding this comment.
We normally extract this outside the test to reduce noise. Can we do the same here? Perhaps create a folder service_group_count with both the test and the data generation function
| const { body: createdRule } = await supertest | ||
| .post(`/api/alerting/rule`) | ||
| .set('kbn-xsrf', 'true') | ||
| .send({ | ||
| params: { | ||
| serviceName: 'synth-go', | ||
| transactionType: '', | ||
| windowSize: 99, | ||
| windowUnit: 'y', | ||
| threshold: 100, | ||
| aggregationType: 'avg', | ||
| environment: 'testing', | ||
| }, | ||
| consumer: 'apm', | ||
| schedule: { interval: '1m' }, | ||
| tags: ['apm'], | ||
| name: 'Latency threshold | synth-go', | ||
| rule_type_id: ApmRuleType.TransactionDuration, | ||
| notify_when: 'onActiveAlert', | ||
| actions: [], | ||
| }); | ||
| ruleId = createdRule.id; | ||
| await waitForActiveAlert({ ruleId, esClient, log }); |
There was a problem hiding this comment.
Extract this to createRule function
| await delay(WAIT_FOR_STATUS_INCREMENT); | ||
| return await waitForActiveAlert({ | ||
| ruleId, | ||
| waitMillis: waitMillis - WAIT_FOR_STATUS_INCREMENT, | ||
| esClient, | ||
| log, | ||
| }); |
There was a problem hiding this comment.
Can you remove this custom retry logic, and instead use p-retry. Perhaps with a factor of 1 (instead of 2).
x-pack/test/apm_api_integration/tests/service_groups/wait_for_active_alert.ts
Show resolved
Hide resolved
…groups-alert-count
| index: apmAlertsIndices.join(','), | ||
| ...searchParams, |
There was a problem hiding this comment.
Let's change the order of this so it's not possible to override index
| index: apmAlertsIndices.join(','), | |
| ...searchParams, | |
| ...searchParams, | |
| index: apmAlertsIndices.join(','), |
There was a problem hiding this comment.
| return promises; | |
| return Promise.all(promises); |
There was a problem hiding this comment.
| return promises; | |
| return Promise.all(promises); |
There was a problem hiding this comment.
Btw can you extract deleteAllServiceGroups so we don't duplicate it
600f7e7 to
0085041
Compare
💚 Build Succeeded
Metrics [docs]Async chunks
Unknown metric groupsESLint disabled in files
ESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: |
Closes #143613
Closes #144420