Skip to content

Commit bfe069f

Browse files
MiroDojkickronickerbornast
authored
feat: Enable xray Opentelementry exporeter
* feat: monitoring dashboard * feat: enable configuring panels - expose prometheus query builders * feat: burn rate prom query and grafana panel * feat: build Grafana dashboard with builder * fix: add xray policy to default collector build * feat: enable multiple batch processors * wip: add endpoint to aws xray exporter config * fix: add missing APS exporter in withDefault * fix: rollback otel collector image version * Make aws xray endpoint prop optional --------- Co-authored-by: Toma <[email protected]> Co-authored-by: Borna Šunjić <[email protected]>
1 parent 73f93e3 commit bfe069f

File tree

16 files changed

+679
-57
lines changed

16 files changed

+679
-57
lines changed

package-lock.json

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"@pulumi/awsx": "^2.21.0",
3939
"@pulumi/pulumi": "^3.146.0",
4040
"@pulumi/random": "^4.17.0",
41+
"@pulumiverse/grafana": "^0.16.3",
4142
"@upstash/pulumi": "^0.3.14",
4243
"yaml": "^2.7.1"
4344
},

src/types/pulumi.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import * as pulumi from '@pulumi/pulumi';
2+
3+
export type WithInput<T extends {}> = {
4+
[K in keyof T]: pulumi.Input<T[K]>;
5+
};
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { default as WebServerSloDashboardBuilder } from "./web-server-slo";
2+
export * as panel from './panels';
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
import { Grafana } from './types';
2+
3+
const percentageFieldConfig = {
4+
unit: 'percent',
5+
min: 0,
6+
max: 100
7+
}
8+
9+
export function createStatPercentagePanel(
10+
title: string,
11+
position: Grafana.Panel.Position,
12+
dataSource: string,
13+
metric: Grafana.Metric
14+
): Grafana.Panel {
15+
return {
16+
title,
17+
gridPos: position,
18+
type: 'stat',
19+
datasource: dataSource,
20+
targets: [{
21+
expr: metric.query,
22+
legendFormat: metric.label
23+
}],
24+
fieldConfig: {
25+
defaults: {
26+
...percentageFieldConfig,
27+
...(metric.thresholds ? {
28+
thresholds: {
29+
mode: 'absolute',
30+
steps: metric.thresholds
31+
}
32+
} : {})
33+
}
34+
}
35+
};
36+
}
37+
38+
export function createTimeSeriesPercentagePanel(
39+
title: string,
40+
position: Grafana.Panel.Position,
41+
dataSource: string,
42+
metric: Grafana.Metric
43+
): Grafana.Panel {
44+
return createTimeSeriesPanel(
45+
title,
46+
position,
47+
dataSource,
48+
metric,
49+
percentageFieldConfig.unit,
50+
percentageFieldConfig.min,
51+
percentageFieldConfig.max
52+
);
53+
}
54+
55+
export function createTimeSeriesPanel(
56+
title: string,
57+
position: Grafana.Panel.Position,
58+
dataSource: string,
59+
metric: Grafana.Metric,
60+
unit?: string,
61+
min?: number,
62+
max?: number
63+
): Grafana.Panel {
64+
return {
65+
title,
66+
type: 'timeseries',
67+
datasource: dataSource,
68+
gridPos: position,
69+
targets: [{
70+
expr: metric.query,
71+
legendFormat: metric.label
72+
}],
73+
fieldConfig: {
74+
defaults: {
75+
unit,
76+
min,
77+
max,
78+
...(metric.thresholds ? {
79+
thresholds: {
80+
mode: 'absolute',
81+
steps: metric.thresholds
82+
}
83+
} : {}),
84+
}
85+
}
86+
};
87+
}
88+
89+
export function createBurnRatePanel(
90+
title: string,
91+
position: Grafana.Panel.Position,
92+
dataSource: string,
93+
metric: Grafana.Metric
94+
): Grafana.Panel {
95+
return {
96+
type: 'stat',
97+
title,
98+
gridPos: position,
99+
datasource: dataSource,
100+
targets: [{
101+
expr: metric.query,
102+
legendFormat: metric.label
103+
}],
104+
options: {
105+
reduceOptions: {
106+
calcs: ['last'],
107+
fields: '',
108+
values: false
109+
},
110+
colorMode: 'value',
111+
graphMode: 'none',
112+
textMode: 'value'
113+
},
114+
fieldConfig: {
115+
defaults: {
116+
unit: 'none',
117+
thresholds: {
118+
mode: 'absolute',
119+
steps: [
120+
{ color: 'green', value: null },
121+
{ color: 'orange', value: 1 },
122+
{ color: 'red', value: 2 }
123+
]
124+
}
125+
}
126+
},
127+
}
128+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import * as pulumi from '@pulumi/pulumi';
2+
import * as grafana from '@pulumiverse/grafana';
3+
4+
// TODO: Should we prefix all namespaces with `Studion`
5+
export namespace Grafana {
6+
// TODO: Create SLO abstraction that enables configuring:
7+
// - panels (long-window SLI, long-window error budget)
8+
// - alerts (long-window burn, short-window burn)
9+
export type Threshold = {
10+
value: number | null;
11+
color: string;
12+
};
13+
export type Metric = {
14+
label: string;
15+
query: string;
16+
thresholds: Threshold[];
17+
};
18+
19+
export type Args = {
20+
title: pulumi.Input<string>;
21+
provider: pulumi.Input<grafana.Provider>;
22+
tags: pulumi.Input<pulumi.Input<string>[]>;
23+
};
24+
25+
export type Panel = {
26+
title: string;
27+
gridPos: Panel.Position;
28+
type: string;
29+
datasource: string;
30+
targets: {
31+
expr: string;
32+
legendFormat: string;
33+
}[];
34+
fieldConfig: {
35+
defaults: {
36+
unit?: string;
37+
min?: number;
38+
max?: number;
39+
color?: {
40+
mode: string;
41+
};
42+
thresholds?: {
43+
mode: string;
44+
steps: Threshold[];
45+
};
46+
custom?: {
47+
lineInterpolation?: string,
48+
spanNulls: boolean
49+
}
50+
};
51+
};
52+
options?: {
53+
colorMode?: string;
54+
graphMode?: string;
55+
justifyMode?: string;
56+
textMode?: string;
57+
reduceOptions?: {
58+
calcs?: string[];
59+
fields?: string;
60+
values?: boolean;
61+
};
62+
};
63+
}
64+
65+
export namespace Panel {
66+
export type Position = {
67+
x: number;
68+
y: number;
69+
w: number;
70+
h: number;
71+
}
72+
}
73+
}

0 commit comments

Comments
 (0)