Skip to content

[APM] Alert counts in Service groups#144484

Merged
MiriamAparicio merged 30 commits intoelastic:mainfrom
ogupte:apm-143613-service-groups-alert-count
Dec 12, 2022
Merged

[APM] Alert counts in Service groups#144484
MiriamAparicio merged 30 commits intoelastic:mainfrom
ogupte:apm-143613-service-groups-alert-count

Conversation

@ogupte
Copy link
Contributor

@ogupte ogupte commented Nov 2, 2022

Closes #143613

Closes #144420

Screen Shot 2022-11-03 at 7 32 39 PM
apm-service-groups-alert-count
Screen Shot 2022-11-03 at 7 34 41 PM
Screen Shot 2022-11-03 at 7 32 21 PM

@ogupte ogupte added release_note:skip Skip the PR/issue when compiling release notes v8.6.0 labels Nov 2, 2022
@ogupte ogupte force-pushed the apm-143613-service-groups-alert-count branch from 118eac2 to cc6719e Compare November 3, 2022 23:35
@ogupte ogupte marked this pull request as ready for review November 3, 2022 23:40
@ogupte ogupte requested a review from a team November 3, 2022 23:40
@ogupte ogupte requested a review from a team as a code owner November 3, 2022 23:40
@ogupte ogupte requested a review from a team November 3, 2022 23:40
@ogupte ogupte requested a review from a team as a code owner November 3, 2022 23:40
@botelastic botelastic bot added the Team:APM - DEPRECATED Use Team:obs-ux-infra_services. label Nov 4, 2022
@elasticmachine
Copy link
Contributor

Pinging @elastic/apm-ui (Team:APM)

Copy link
Contributor

@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.

LGTM

Copy link
Contributor

@dgieselaar dgieselaar left a comment

Choose a reason for hiding this comment

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

@ogupte can you add API tests?

Copy link
Contributor

@cauemarcondes cauemarcondes left a comment

Choose a reason for hiding this comment

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

Some suggestions.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is it really needed? Can we just render the translation if serviceCountis defined?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

@ogupte ogupte removed the request for review from a team November 10, 2022 09:24
Copy link
Contributor

@fkanout fkanout left a comment

Choose a reason for hiding this comment

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

Actionable Observability changes LGTM

const start = Date.now() - 24 * 60 * 60 * 1000;
const end = Date.now();

async function callApi() {
Copy link
Member

@sorenlouv sorenlouv Dec 1, 2022

Choose a reason for hiding this comment

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

Suggested change
async function callApi() {
async function getServiceGroupCounts() {

type: string;
}>;

async function deleteServiceGroups() {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
async function deleteServiceGroups() {
async function deleteAllServiceGroups() {

Comment on lines +65 to +73
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);
Copy link
Member

Choose a reason for hiding this comment

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

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, makes sense, I used our own for the e2e tests

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I saw :)

Comment on lines +77 to +149
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;
});
Copy link
Member

Choose a reason for hiding this comment

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

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

Comment on lines +167 to +189
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 });
Copy link
Member

Choose a reason for hiding this comment

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

Extract this to createRule function

Comment on lines +64 to +70
await delay(WAIT_FOR_STATUS_INCREMENT);
return await waitForActiveAlert({
ruleId,
waitMillis: waitMillis - WAIT_FOR_STATUS_INCREMENT,
esClient,
log,
});
Copy link
Member

Choose a reason for hiding this comment

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

Can you remove this custom retry logic, and instead use p-retry. Perhaps with a factor of 1 (instead of 2).

Comment on lines +37 to +38
index: apmAlertsIndices.join(','),
...searchParams,
Copy link
Member

@sorenlouv sorenlouv Dec 2, 2022

Choose a reason for hiding this comment

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

Let's change the order of this so it's not possible to override index

Suggested change
index: apmAlertsIndices.join(','),
...searchParams,
...searchParams,
index: apmAlertsIndices.join(','),

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return promises;
return Promise.all(promises);

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return promises;
return Promise.all(promises);

Copy link
Member

Choose a reason for hiding this comment

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

Btw can you extract deleteAllServiceGroups so we don't duplicate it

@MiriamAparicio MiriamAparicio force-pushed the apm-143613-service-groups-alert-count branch from 600f7e7 to 0085041 Compare December 12, 2022 09:13
@kibana-ci
Copy link

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
apm 3.2MB 3.2MB +472.0B
Unknown metric groups

ESLint disabled in files

id before after diff
osquery 1 2 +1

ESLint disabled line counts

id before after diff
enterpriseSearch 19 21 +2
fleet 60 66 +6
osquery 109 115 +6
securitySolution 445 451 +6
total +20

Total ESLint disabled count

id before after diff
enterpriseSearch 20 22 +2
fleet 69 75 +6
osquery 110 117 +7
securitySolution 521 527 +6
total +21

History

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

Copy link
Member

@sorenlouv sorenlouv left a comment

Choose a reason for hiding this comment

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

I'm good with merging this as-is so we can unblock #146701.
Please create an issue with the follow-up items that were left out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:APM - DEPRECATED Use Team:obs-ux-infra_services. v8.7.0

Projects

None yet