-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(slo): Improve fixtures and storybook cases (#149639)
- Loading branch information
Showing
15 changed files
with
307 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { SLOWithSummaryResponse } from '@kbn/slo-schema'; | ||
|
||
export const buildOccurrencesObjective = ( | ||
params: Partial<SLOWithSummaryResponse['objective']> = {} | ||
): SLOWithSummaryResponse['objective'] => { | ||
return { | ||
target: 0.99, | ||
...params, | ||
}; | ||
}; | ||
|
||
export const buildTimeslicesObjective = ( | ||
params: Partial<SLOWithSummaryResponse['objective']> = {} | ||
): SLOWithSummaryResponse['objective'] => { | ||
return { | ||
target: 0.99, | ||
timesliceTarget: 0.95, | ||
timesliceWindow: '5m', | ||
...params, | ||
}; | ||
}; | ||
|
||
export const buildHealthySummary = ( | ||
params: Partial<SLOWithSummaryResponse['summary']> = {} | ||
): SLOWithSummaryResponse['summary'] => { | ||
return { | ||
status: 'HEALTHY', | ||
sliValue: 0.99872, | ||
errorBudget: { | ||
initial: 0.02, | ||
consumed: 0.064, | ||
remaining: 0.936, | ||
isEstimated: false, | ||
}, | ||
...params, | ||
}; | ||
}; | ||
|
||
export const buildViolatedSummary = ( | ||
params: Partial<SLOWithSummaryResponse['summary']> = {} | ||
): SLOWithSummaryResponse['summary'] => { | ||
return { | ||
status: 'VIOLATED', | ||
sliValue: 0.97, | ||
errorBudget: { | ||
initial: 0.02, | ||
consumed: 1, | ||
remaining: 0, | ||
isEstimated: false, | ||
}, | ||
...params, | ||
}; | ||
}; | ||
|
||
export const buildNoDataSummary = ( | ||
params: Partial<SLOWithSummaryResponse['summary']> = {} | ||
): SLOWithSummaryResponse['summary'] => { | ||
return { | ||
status: 'NO_DATA', | ||
sliValue: -1, | ||
errorBudget: { | ||
initial: 0.02, | ||
consumed: 0, | ||
remaining: 1, | ||
isEstimated: false, | ||
}, | ||
...params, | ||
}; | ||
}; | ||
|
||
export const buildDegradingSummary = ( | ||
params: Partial<SLOWithSummaryResponse['summary']> = {} | ||
): SLOWithSummaryResponse['summary'] => { | ||
return { | ||
status: 'DEGRADING', | ||
sliValue: 0.97, | ||
errorBudget: { | ||
initial: 0.02, | ||
consumed: 0.88, | ||
remaining: 0.12, | ||
isEstimated: true, | ||
}, | ||
...params, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { SLOWithSummaryResponse } from '@kbn/slo-schema'; | ||
|
||
export const buildApmAvailabilityIndicator = ( | ||
params: Partial<SLOWithSummaryResponse['indicator']['params']> = {} | ||
): SLOWithSummaryResponse['indicator'] => { | ||
return { | ||
type: 'sli.apm.transactionErrorRate', | ||
params: { | ||
environment: 'development', | ||
service: 'o11y-app', | ||
transactionType: 'request', | ||
transactionName: 'GET /flaky', | ||
goodStatusCodes: ['2xx', '3xx', '4xx'], | ||
...params, | ||
}, | ||
}; | ||
}; | ||
|
||
export const buildApmLatencyIndicator = ( | ||
params: Partial<SLOWithSummaryResponse['indicator']['params']> = {} | ||
): SLOWithSummaryResponse['indicator'] => { | ||
return { | ||
type: 'sli.apm.transactionDuration', | ||
params: { | ||
environment: 'development', | ||
service: 'o11y-app', | ||
transactionType: 'request', | ||
transactionName: 'GET /slow', | ||
'threshold.us': 5000000, | ||
...params, | ||
}, | ||
}; | ||
}; | ||
|
||
export const buildCustomKqlIndicator = ( | ||
params: Partial<SLOWithSummaryResponse['indicator']['params']> = {} | ||
): SLOWithSummaryResponse['indicator'] => { | ||
return { | ||
type: 'sli.kql.custom', | ||
params: { | ||
index: 'some_logs*', | ||
good: 'latency < 300', | ||
total: 'latency > 0', | ||
filter: 'labels.eventId: event-0', | ||
...params, | ||
}, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
x-pack/plugins/observability/public/data/slo/time_window.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { SLOWithSummaryResponse } from '@kbn/slo-schema'; | ||
|
||
export const buildRollingTimeWindow = ( | ||
params: Partial<SLOWithSummaryResponse['timeWindow']> = {} | ||
): SLOWithSummaryResponse['timeWindow'] => { | ||
return { | ||
duration: '30d', | ||
isRolling: true, | ||
...params, | ||
}; | ||
}; | ||
|
||
export const buildCalendarAlignedTimeWindow = ( | ||
params: Partial<SLOWithSummaryResponse['timeWindow']> = {} | ||
): SLOWithSummaryResponse['timeWindow'] => { | ||
return { | ||
duration: '1M', | ||
calendar: { startTime: '2023-01-01T00:00:00.000Z' }, | ||
...params, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.