mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[APM] Fix bug that causes watcher emails to fail (#19071)
This commit is contained in:
parent
0940f5755d
commit
3bf6c43602
3 changed files with 11 additions and 5 deletions
|
@ -31,7 +31,7 @@ Object {
|
|||
"html": "Your service \\"opbeans-node\\" has error groups which exceeds 10 occurrences within \\"24h\\"<br/><br/><br/><strong>this is a string</strong><br/>N/A<br/>7761 occurrences<br/><br/><strong>foo</strong><br/><anonymous> (server/coffee.js)<br/>7752 occurrences<br/><br/><strong>socket hang up</strong><br/>createHangUpError (_http_client.js)<br/>3887 occurrences<br/><br/><strong>this will not get captured by express</strong><br/><anonymous> (server/coffee.js)<br/>3886 occurrences<br/>",
|
||||
},
|
||||
"subject": "\\"opbeans-node\\" has error groups which exceeds the threshold",
|
||||
"to": "my@email.dk",
|
||||
"to": "my@email.dk,mySecond@email.dk",
|
||||
},
|
||||
},
|
||||
"log_error": Object {
|
||||
|
@ -128,6 +128,7 @@ Object {
|
|||
"metadata": Object {
|
||||
"emails": Array [
|
||||
"my@email.dk",
|
||||
"mySecond@email.dk",
|
||||
],
|
||||
"serviceName": "opbeans-node",
|
||||
"slackUrlPath": "/services/slackid1/slackid2/slackid3",
|
||||
|
|
|
@ -26,7 +26,7 @@ describe('createErrorGroupWatch', () => {
|
|||
jest.spyOn(rest, 'createWatch').mockReturnValue();
|
||||
|
||||
createWatchResponse = await createErrorGroupWatch({
|
||||
emails: ['my@email.dk'],
|
||||
emails: ['my@email.dk', 'mySecond@email.dk'],
|
||||
schedule: {
|
||||
daily: {
|
||||
at: '08:00'
|
||||
|
@ -63,7 +63,9 @@ describe('createErrorGroupWatch', () => {
|
|||
});
|
||||
|
||||
it('should format email correctly', () => {
|
||||
expect(tmpl.actions.email.email.to).toBe('my@email.dk');
|
||||
expect(tmpl.actions.email.email.to).toEqual(
|
||||
'my@email.dk,mySecond@email.dk'
|
||||
);
|
||||
expect(tmpl.actions.email.email.subject).toBe(
|
||||
'"opbeans-node" has error groups which exceeds the threshold'
|
||||
);
|
||||
|
@ -85,7 +87,10 @@ describe('createErrorGroupWatch', () => {
|
|||
// Recusively iterate a nested structure and render strings as mustache templates
|
||||
function renderMustache(input, ctx) {
|
||||
if (isString(input)) {
|
||||
return mustache.render(input, { ctx });
|
||||
return mustache.render(input, {
|
||||
ctx,
|
||||
join: () => (text, render) => render(`{{${text}}}`, { ctx })
|
||||
});
|
||||
}
|
||||
|
||||
if (isArray(input)) {
|
||||
|
|
|
@ -160,7 +160,7 @@ export async function createErrorGroupWatch({
|
|||
if (!isEmpty(emails)) {
|
||||
body.actions.email = {
|
||||
email: {
|
||||
to: '{{ctx.metadata.emails}}',
|
||||
to: '{{#join}}ctx.metadata.emails{{/join}}',
|
||||
subject: `"{{ctx.metadata.serviceName}}" has error groups which exceeds the threshold`,
|
||||
body: {
|
||||
html: emailTemplate
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue