@studion/infra-code-blocks 2.0.0-alpha.5 → 2.0.0-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/dist/components/cloudfront/index.d.ts.map +1 -1
  2. package/dist/components/cloudfront/index.js +19 -24
  3. package/dist/components/database/builder.d.ts +2 -3
  4. package/dist/components/database/builder.d.ts.map +1 -1
  5. package/dist/components/database/builder.js +12 -12
  6. package/dist/components/database/database-replica.d.ts.map +1 -1
  7. package/dist/components/database/database-replica.js +1 -0
  8. package/dist/components/database/index.d.ts +9 -5
  9. package/dist/components/database/index.d.ts.map +1 -1
  10. package/dist/components/database/index.js +30 -30
  11. package/dist/components/grafana/builder.d.ts +21 -0
  12. package/dist/components/grafana/builder.d.ts.map +1 -0
  13. package/dist/components/grafana/builder.js +57 -0
  14. package/dist/components/grafana/connections/amp-connection.d.ts +23 -0
  15. package/dist/components/grafana/connections/amp-connection.d.ts.map +1 -0
  16. package/dist/components/grafana/connections/amp-connection.js +73 -0
  17. package/dist/components/grafana/connections/cloudwatch-logs-connection.d.ts +18 -0
  18. package/dist/components/grafana/connections/cloudwatch-logs-connection.d.ts.map +1 -0
  19. package/dist/components/grafana/connections/cloudwatch-logs-connection.js +59 -0
  20. package/dist/components/grafana/connections/connection.d.ts +20 -0
  21. package/dist/components/grafana/connections/connection.d.ts.map +1 -0
  22. package/dist/components/grafana/connections/connection.js +57 -0
  23. package/dist/components/grafana/connections/index.d.ts +5 -0
  24. package/dist/components/grafana/connections/index.d.ts.map +1 -0
  25. package/dist/components/grafana/connections/index.js +11 -0
  26. package/dist/components/grafana/connections/xray-connection.d.ts +22 -0
  27. package/dist/components/grafana/connections/xray-connection.d.ts.map +1 -0
  28. package/dist/components/grafana/connections/xray-connection.js +76 -0
  29. package/dist/components/grafana/dashboards/builder.d.ts +22 -0
  30. package/dist/components/grafana/dashboards/builder.d.ts.map +1 -0
  31. package/dist/components/grafana/dashboards/builder.js +53 -0
  32. package/dist/components/grafana/dashboards/index.d.ts +2 -2
  33. package/dist/components/grafana/dashboards/index.d.ts.map +1 -1
  34. package/dist/components/grafana/dashboards/index.js +5 -4
  35. package/dist/components/grafana/dashboards/slo.d.ts +18 -0
  36. package/dist/components/grafana/dashboards/slo.d.ts.map +1 -0
  37. package/dist/components/grafana/dashboards/slo.js +77 -0
  38. package/dist/components/grafana/grafana.d.ts +19 -0
  39. package/dist/components/grafana/grafana.d.ts.map +1 -0
  40. package/dist/components/grafana/grafana.js +24 -0
  41. package/dist/components/grafana/index.d.ts +4 -0
  42. package/dist/components/grafana/index.d.ts.map +1 -1
  43. package/dist/components/grafana/index.js +11 -1
  44. package/dist/components/grafana/panels/availability.d.ts +15 -0
  45. package/dist/components/grafana/panels/availability.d.ts.map +1 -0
  46. package/dist/components/grafana/panels/availability.js +20 -0
  47. package/dist/components/grafana/panels/helpers.d.ts +6 -0
  48. package/dist/components/grafana/panels/helpers.d.ts.map +1 -0
  49. package/dist/components/grafana/panels/index.d.ts +6 -0
  50. package/dist/components/grafana/panels/index.d.ts.map +1 -0
  51. package/dist/components/grafana/panels/index.js +21 -0
  52. package/dist/components/grafana/panels/latency.d.ts +31 -0
  53. package/dist/components/grafana/panels/latency.d.ts.map +1 -0
  54. package/dist/components/grafana/panels/latency.js +36 -0
  55. package/dist/components/grafana/panels/success-rate.d.ts +22 -0
  56. package/dist/components/grafana/panels/success-rate.d.ts.map +1 -0
  57. package/dist/components/grafana/panels/success-rate.js +28 -0
  58. package/dist/components/grafana/panels/types.d.ts +57 -0
  59. package/dist/components/grafana/panels/types.d.ts.map +1 -0
  60. package/dist/components/web-server/index.js +1 -1
  61. package/package.json +30 -26
  62. package/dist/components/grafana/dashboards/panels.d.ts +0 -6
  63. package/dist/components/grafana/dashboards/panels.d.ts.map +0 -1
  64. package/dist/components/grafana/dashboards/types.d.ts +0 -66
  65. package/dist/components/grafana/dashboards/types.d.ts.map +0 -1
  66. package/dist/components/grafana/dashboards/web-server-slo.d.ts +0 -17
  67. package/dist/components/grafana/dashboards/web-server-slo.d.ts.map +0 -1
  68. package/dist/components/grafana/dashboards/web-server-slo.js +0 -98
  69. /package/dist/components/grafana/{dashboards/panels.js → panels/helpers.js} +0 -0
  70. /package/dist/components/grafana/{dashboards → panels}/types.js +0 -0
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CloudWatchLogsConnection = void 0;
4
+ const aws = require("@pulumi/aws");
5
+ const pulumi = require("@pulumi/pulumi");
6
+ const grafana = require("@pulumiverse/grafana");
7
+ const merge_with_defaults_1 = require("../../../shared/merge-with-defaults");
8
+ const connection_1 = require("./connection");
9
+ const awsConfig = new pulumi.Config('aws');
10
+ const defaults = {
11
+ region: awsConfig.require('region'),
12
+ };
13
+ class CloudWatchLogsConnection extends connection_1.GrafanaConnection {
14
+ name;
15
+ dataSource;
16
+ rolePolicy;
17
+ constructor(name, args, opts = {}) {
18
+ super('studion:grafana:CloudWatchLogsConnection', name, args, opts);
19
+ const argsWithDefaults = (0, merge_with_defaults_1.mergeWithDefaults)(defaults, args);
20
+ this.name = name;
21
+ this.rolePolicy = this.createRolePolicy();
22
+ this.dataSource = this.createDataSource(argsWithDefaults.region);
23
+ this.registerOutputs();
24
+ }
25
+ createRolePolicy() {
26
+ const policy = aws.iam.getPolicyDocumentOutput({
27
+ statements: [
28
+ {
29
+ effect: 'Allow',
30
+ actions: [
31
+ 'logs:DescribeLogGroups',
32
+ 'logs:GetLogGroupFields',
33
+ 'logs:StartQuery',
34
+ 'logs:StopQuery',
35
+ 'logs:GetQueryResults',
36
+ 'logs:GetLogEvents',
37
+ ],
38
+ resources: ['*'],
39
+ },
40
+ ],
41
+ });
42
+ return new aws.iam.RolePolicy(`${this.name}-cloudwatch-logs-policy`, {
43
+ role: this.role.id,
44
+ policy: policy.json,
45
+ }, { parent: this });
46
+ }
47
+ createDataSource(region) {
48
+ return new grafana.oss.DataSource(`${this.name}-cloudwatch-logs-datasource`, {
49
+ name: this.dataSourceName,
50
+ type: 'cloudwatch',
51
+ jsonDataEncoded: pulumi.jsonStringify({
52
+ authType: 'grafana_assume_role',
53
+ assumeRoleArn: this.role.arn,
54
+ defaultRegion: region,
55
+ }),
56
+ }, { parent: this });
57
+ }
58
+ }
59
+ exports.CloudWatchLogsConnection = CloudWatchLogsConnection;
@@ -0,0 +1,20 @@
1
+ import * as aws from '@pulumi/aws';
2
+ import * as pulumi from '@pulumi/pulumi';
3
+ import * as grafana from '@pulumiverse/grafana';
4
+ export declare namespace GrafanaConnection {
5
+ type Args = {
6
+ awsAccountId: string;
7
+ dataSourceName?: string;
8
+ };
9
+ type CreateConnection = (opts: pulumi.ComponentResourceOptions) => GrafanaConnection;
10
+ }
11
+ export declare abstract class GrafanaConnection extends pulumi.ComponentResource {
12
+ readonly name: string;
13
+ readonly role: aws.iam.Role;
14
+ abstract readonly dataSource: grafana.oss.DataSource;
15
+ protected readonly dataSourceName: string;
16
+ constructor(type: string, name: string, args: GrafanaConnection.Args, opts?: pulumi.ComponentResourceOptions);
17
+ protected getStackSlug(): string;
18
+ private createIamRole;
19
+ }
20
+ //# sourceMappingURL=connection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../../../src/components/grafana/connections/connection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC;AACnC,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;AACzC,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAKhD,yBAAiB,iBAAiB,CAAC;IACjC,KAAY,IAAI,GAAG;QACjB,YAAY,EAAE,MAAM,CAAC;QACrB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;IAEF,KAAY,gBAAgB,GAAG,CAC7B,IAAI,EAAE,MAAM,CAAC,wBAAwB,KAClC,iBAAiB,CAAC;CACxB;AAED,8BAAsB,iBAAkB,SAAQ,MAAM,CAAC,iBAAiB;IACtE,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,IAAI,EAAE,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC;IACnC,kBAAyB,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC;IAC5D,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;gBAGxC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,iBAAiB,CAAC,IAAI,EAC5B,IAAI,GAAE,MAAM,CAAC,wBAA6B;IAa5C,SAAS,CAAC,YAAY,IAAI,MAAM;IAYhC,OAAO,CAAC,aAAa;CAmCtB"}
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GrafanaConnection = void 0;
4
+ const aws = require("@pulumi/aws");
5
+ const pulumi = require("@pulumi/pulumi");
6
+ const grafana = require("@pulumiverse/grafana");
7
+ const common_tags_1 = require("../../../shared/common-tags");
8
+ const grafanaConfig = new pulumi.Config('grafana');
9
+ class GrafanaConnection extends pulumi.ComponentResource {
10
+ name;
11
+ role;
12
+ dataSourceName;
13
+ constructor(type, name, args, opts = {}) {
14
+ super(type, name, {}, opts);
15
+ this.name = name;
16
+ this.dataSourceName = args.dataSourceName ?? `${name}-datasource`;
17
+ this.role = this.createIamRole(args.awsAccountId);
18
+ this.registerOutputs();
19
+ }
20
+ getStackSlug() {
21
+ const grafanaUrl = grafanaConfig.get('url') ?? process.env.GRAFANA_URL;
22
+ if (!grafanaUrl) {
23
+ throw new Error('Grafana URL is not configured. Set it via Pulumi config (grafana:url) or GRAFANA_URL env var.');
24
+ }
25
+ return new URL(grafanaUrl).hostname.split('.')[0];
26
+ }
27
+ createIamRole(awsAccountId) {
28
+ const stackSlug = this.getStackSlug();
29
+ const grafanaStack = grafana.cloud.getStack({ slug: stackSlug });
30
+ const assumeRolePolicy = aws.iam.getPolicyDocumentOutput({
31
+ statements: [
32
+ {
33
+ effect: 'Allow',
34
+ principals: [
35
+ {
36
+ type: 'AWS',
37
+ identifiers: [`arn:aws:iam::${awsAccountId}:root`],
38
+ },
39
+ ],
40
+ actions: ['sts:AssumeRole'],
41
+ conditions: [
42
+ {
43
+ test: 'StringEquals',
44
+ variable: 'sts:ExternalId',
45
+ values: [pulumi.output(grafanaStack).id],
46
+ },
47
+ ],
48
+ },
49
+ ],
50
+ });
51
+ return new aws.iam.Role(`${this.name}-grafana-iam-role`, {
52
+ assumeRolePolicy: assumeRolePolicy.json,
53
+ tags: common_tags_1.commonTags,
54
+ }, { parent: this });
55
+ }
56
+ }
57
+ exports.GrafanaConnection = GrafanaConnection;
@@ -0,0 +1,5 @@
1
+ export { GrafanaConnection } from './connection';
2
+ export { AMPConnection } from './amp-connection';
3
+ export { CloudWatchLogsConnection } from './cloudwatch-logs-connection';
4
+ export { XRayConnection } from './xray-connection';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/grafana/connections/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.XRayConnection = exports.CloudWatchLogsConnection = exports.AMPConnection = exports.GrafanaConnection = void 0;
4
+ var connection_1 = require("./connection");
5
+ Object.defineProperty(exports, "GrafanaConnection", { enumerable: true, get: function () { return connection_1.GrafanaConnection; } });
6
+ var amp_connection_1 = require("./amp-connection");
7
+ Object.defineProperty(exports, "AMPConnection", { enumerable: true, get: function () { return amp_connection_1.AMPConnection; } });
8
+ var cloudwatch_logs_connection_1 = require("./cloudwatch-logs-connection");
9
+ Object.defineProperty(exports, "CloudWatchLogsConnection", { enumerable: true, get: function () { return cloudwatch_logs_connection_1.CloudWatchLogsConnection; } });
10
+ var xray_connection_1 = require("./xray-connection");
11
+ Object.defineProperty(exports, "XRayConnection", { enumerable: true, get: function () { return xray_connection_1.XRayConnection; } });
@@ -0,0 +1,22 @@
1
+ import * as aws from '@pulumi/aws';
2
+ import * as pulumi from '@pulumi/pulumi';
3
+ import * as grafana from '@pulumiverse/grafana';
4
+ import { GrafanaConnection } from './connection';
5
+ export declare namespace XRayConnection {
6
+ type Args = GrafanaConnection.Args & {
7
+ region?: string;
8
+ pluginVersion?: string;
9
+ installPlugin?: boolean;
10
+ };
11
+ }
12
+ export declare class XRayConnection extends GrafanaConnection {
13
+ readonly name: string;
14
+ readonly dataSource: grafana.oss.DataSource;
15
+ readonly rolePolicy: aws.iam.RolePolicy;
16
+ readonly plugin?: grafana.cloud.PluginInstallation;
17
+ constructor(name: string, args: XRayConnection.Args, opts?: pulumi.ComponentResourceOptions);
18
+ private createRolePolicy;
19
+ private createPlugin;
20
+ private createDataSource;
21
+ }
22
+ //# sourceMappingURL=xray-connection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xray-connection.d.ts","sourceRoot":"","sources":["../../../../src/components/grafana/connections/xray-connection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC;AACnC,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;AACzC,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAKjD,yBAAiB,cAAc,CAAC;IAC9B,KAAY,IAAI,GAAG,iBAAiB,CAAC,IAAI,GAAG;QAC1C,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,aAAa,CAAC,EAAE,OAAO,CAAC;KACzB,CAAC;CACH;AAQD,qBAAa,cAAe,SAAQ,iBAAiB;IACnD,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC;IACnD,SAAgB,UAAU,EAAE,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC;IAC/C,SAAgB,MAAM,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,kBAAkB,CAAC;gBAGxD,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,cAAc,CAAC,IAAI,EACzB,IAAI,GAAE,MAAM,CAAC,wBAA6B;IAmB5C,OAAO,CAAC,gBAAgB;IA+BxB,OAAO,CAAC,YAAY;IAcpB,OAAO,CAAC,gBAAgB;CAezB"}
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.XRayConnection = void 0;
4
+ const aws = require("@pulumi/aws");
5
+ const pulumi = require("@pulumi/pulumi");
6
+ const grafana = require("@pulumiverse/grafana");
7
+ const merge_with_defaults_1 = require("../../../shared/merge-with-defaults");
8
+ const connection_1 = require("./connection");
9
+ const awsConfig = new pulumi.Config('aws');
10
+ const pluginName = 'grafana-x-ray-datasource';
11
+ const defaults = {
12
+ region: awsConfig.require('region'),
13
+ pluginVersion: 'latest',
14
+ installPlugin: true,
15
+ };
16
+ class XRayConnection extends connection_1.GrafanaConnection {
17
+ name;
18
+ dataSource;
19
+ rolePolicy;
20
+ plugin;
21
+ constructor(name, args, opts = {}) {
22
+ super('studion:grafana:XRayConnection', name, args, opts);
23
+ const argsWithDefaults = (0, merge_with_defaults_1.mergeWithDefaults)(defaults, args);
24
+ this.name = name;
25
+ this.rolePolicy = this.createRolePolicy();
26
+ if (argsWithDefaults.installPlugin) {
27
+ this.plugin = this.createPlugin(argsWithDefaults.pluginVersion);
28
+ }
29
+ this.dataSource = this.createDataSource(argsWithDefaults.region);
30
+ this.registerOutputs();
31
+ }
32
+ createRolePolicy() {
33
+ const policy = aws.iam.getPolicyDocumentOutput({
34
+ statements: [
35
+ {
36
+ effect: 'Allow',
37
+ actions: [
38
+ 'xray:BatchGetTraces',
39
+ 'xray:GetTraceSummaries',
40
+ 'xray:GetTraceGraph',
41
+ 'xray:GetGroups',
42
+ 'xray:GetTimeSeriesServiceStatistics',
43
+ 'xray:GetInsightSummaries',
44
+ 'xray:GetInsight',
45
+ 'xray:GetServiceGraph',
46
+ 'ec2:DescribeRegions',
47
+ ],
48
+ resources: ['*'],
49
+ },
50
+ ],
51
+ });
52
+ return new aws.iam.RolePolicy(`${this.name}-x-ray-policy`, {
53
+ role: this.role.id,
54
+ policy: policy.json,
55
+ }, { parent: this });
56
+ }
57
+ createPlugin(pluginVersion) {
58
+ return new grafana.cloud.PluginInstallation(`${this.name}-x-ray-plugin`, {
59
+ stackSlug: this.getStackSlug(),
60
+ slug: pluginName,
61
+ version: pluginVersion,
62
+ }, { parent: this });
63
+ }
64
+ createDataSource(region) {
65
+ return new grafana.oss.DataSource(`${this.name}-x-ray-datasource`, {
66
+ name: this.dataSourceName,
67
+ type: pluginName,
68
+ jsonDataEncoded: pulumi.jsonStringify({
69
+ authType: 'grafana_assume_role',
70
+ assumeRoleArn: this.role.arn,
71
+ defaultRegion: region,
72
+ }),
73
+ }, { dependsOn: this.plugin ? [this.plugin] : [], parent: this });
74
+ }
75
+ }
76
+ exports.XRayConnection = XRayConnection;
@@ -0,0 +1,22 @@
1
+ import * as pulumi from '@pulumi/pulumi';
2
+ import * as grafana from '@pulumiverse/grafana';
3
+ import { Panel } from '../panels/types';
4
+ export declare namespace GrafanaDashboardBuilder {
5
+ type Config = {
6
+ timezone?: string;
7
+ refresh?: string;
8
+ };
9
+ type CreateDashboard = (folder?: grafana.oss.Folder, opts?: pulumi.ComponentResourceOptions) => grafana.oss.Dashboard;
10
+ }
11
+ export declare class GrafanaDashboardBuilder {
12
+ private readonly name;
13
+ private readonly panels;
14
+ private configuration;
15
+ private title?;
16
+ constructor(name: string);
17
+ withConfig(options: GrafanaDashboardBuilder.Config): this;
18
+ withTitle(title: string): this;
19
+ addPanel(panel: Panel): this;
20
+ build(): GrafanaDashboardBuilder.CreateDashboard;
21
+ }
22
+ //# sourceMappingURL=builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../../../src/components/grafana/dashboards/builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;AACzC,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAGxC,yBAAiB,uBAAuB,CAAC;IACvC,KAAY,MAAM,GAAG;QACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IAEF,KAAY,eAAe,GAAG,CAC5B,MAAM,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,MAAM,EAC3B,IAAI,CAAC,EAAE,MAAM,CAAC,wBAAwB,KACnC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;CAC5B;AAOD,qBAAa,uBAAuB;IAClC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;IACtC,OAAO,CAAC,aAAa,CAAsC;IAC3D,OAAO,CAAC,KAAK,CAAC,CAAS;gBAEX,IAAI,EAAE,MAAM;IAIxB,UAAU,CAAC,OAAO,EAAE,uBAAuB,CAAC,MAAM,GAAG,IAAI;IAMzD,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAM9B,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAM5B,KAAK,IAAI,uBAAuB,CAAC,eAAe;CAgCjD"}
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GrafanaDashboardBuilder = void 0;
4
+ const pulumi = require("@pulumi/pulumi");
5
+ const grafana = require("@pulumiverse/grafana");
6
+ const merge_with_defaults_1 = require("../../../shared/merge-with-defaults");
7
+ const defaults = {
8
+ timezone: 'browser',
9
+ refresh: '10s',
10
+ };
11
+ class GrafanaDashboardBuilder {
12
+ name;
13
+ panels = [];
14
+ configuration = {};
15
+ title;
16
+ constructor(name) {
17
+ this.name = name;
18
+ }
19
+ withConfig(options) {
20
+ this.configuration = options;
21
+ return this;
22
+ }
23
+ withTitle(title) {
24
+ this.title = title;
25
+ return this;
26
+ }
27
+ addPanel(panel) {
28
+ this.panels.push(panel);
29
+ return this;
30
+ }
31
+ build() {
32
+ if (!this.title) {
33
+ throw new Error('Dashboard title is required. Call withTitle() to set it.');
34
+ }
35
+ if (!this.panels.length) {
36
+ throw new Error('At least one panel is required. Call addPanel() to add a panel.');
37
+ }
38
+ const { name, title, panels } = this;
39
+ const options = (0, merge_with_defaults_1.mergeWithDefaults)(defaults, this.configuration);
40
+ return (folder, opts) => {
41
+ return new grafana.oss.Dashboard(`${name}-dashboard`, {
42
+ folder: folder?.uid,
43
+ configJson: pulumi.jsonStringify({
44
+ title,
45
+ timezone: options.timezone,
46
+ refresh: options.refresh,
47
+ panels,
48
+ }),
49
+ }, opts);
50
+ };
51
+ }
52
+ }
53
+ exports.GrafanaDashboardBuilder = GrafanaDashboardBuilder;
@@ -1,3 +1,3 @@
1
- export { default as WebServerSloDashboardBuilder } from './web-server-slo';
2
- export * as panel from './panels';
1
+ export { GrafanaDashboardBuilder as DashboardBuilder } from './builder';
2
+ export { createSloDashboard } from './slo';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/grafana/dashboards/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,KAAK,KAAK,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/grafana/dashboards/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,IAAI,gBAAgB,EAAE,MAAM,WAAW,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.panel = exports.WebServerSloDashboardBuilder = void 0;
4
- var web_server_slo_1 = require("./web-server-slo");
5
- Object.defineProperty(exports, "WebServerSloDashboardBuilder", { enumerable: true, get: function () { return web_server_slo_1.default; } });
6
- exports.panel = require("./panels");
3
+ exports.createSloDashboard = exports.DashboardBuilder = void 0;
4
+ var builder_1 = require("./builder");
5
+ Object.defineProperty(exports, "DashboardBuilder", { enumerable: true, get: function () { return builder_1.GrafanaDashboardBuilder; } });
6
+ var slo_1 = require("./slo");
7
+ Object.defineProperty(exports, "createSloDashboard", { enumerable: true, get: function () { return slo_1.createSloDashboard; } });
@@ -0,0 +1,18 @@
1
+ import { GrafanaDashboardBuilder } from './builder';
2
+ import { queries as promQ } from '../../prometheus';
3
+ export declare namespace SloDashboard {
4
+ type Args = {
5
+ name: string;
6
+ title: string;
7
+ ampNamespace: string;
8
+ filter: string;
9
+ dataSourceName: string;
10
+ target?: number;
11
+ window?: promQ.TimeRange;
12
+ shortWindow?: promQ.TimeRange;
13
+ targetLatency?: number;
14
+ dashboardConfig?: GrafanaDashboardBuilder.Config;
15
+ };
16
+ }
17
+ export declare function createSloDashboard(config: SloDashboard.Args): GrafanaDashboardBuilder.CreateDashboard;
18
+ //# sourceMappingURL=slo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slo.d.ts","sourceRoot":"","sources":["../../../../src/components/grafana/dashboards/slo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAiBpD,yBAAiB,YAAY,CAAC;IAC5B,KAAY,IAAI,GAAG;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,YAAY,EAAE,MAAM,CAAC;QACrB,MAAM,EAAE,MAAM,CAAC;QACf,cAAc,EAAE,MAAM,CAAC;QACvB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;QACzB,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;QAC9B,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,eAAe,CAAC,EAAE,uBAAuB,CAAC,MAAM,CAAC;KAClD,CAAC;CACH;AAUD,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,YAAY,CAAC,IAAI,GACxB,uBAAuB,CAAC,eAAe,CAwFzC"}
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createSloDashboard = createSloDashboard;
4
+ const merge_with_defaults_1 = require("../../../shared/merge-with-defaults");
5
+ const builder_1 = require("./builder");
6
+ const availability_1 = require("../panels/availability");
7
+ const success_rate_1 = require("../panels/success-rate");
8
+ const latency_1 = require("../panels/latency");
9
+ const defaults = {
10
+ target: 0.99,
11
+ window: '30d',
12
+ shortWindow: '5m',
13
+ targetLatency: 250,
14
+ dashboardConfig: {},
15
+ };
16
+ function createSloDashboard(config) {
17
+ const argsWithDefaults = (0, merge_with_defaults_1.mergeWithDefaults)(defaults, config);
18
+ const { target, window, shortWindow, targetLatency, ampNamespace, dataSourceName, filter, } = argsWithDefaults;
19
+ return new builder_1.GrafanaDashboardBuilder(config.name)
20
+ .withConfig(argsWithDefaults.dashboardConfig)
21
+ .withTitle(argsWithDefaults.title)
22
+ .addPanel((0, availability_1.createAvailabilityPanel)({ target, window, ampNamespace, dataSourceName }))
23
+ .addPanel((0, availability_1.createAvailabilityBurnRatePanel)({
24
+ target,
25
+ window,
26
+ ampNamespace,
27
+ dataSourceName,
28
+ }))
29
+ .addPanel((0, success_rate_1.createSuccessRatePanel)({
30
+ target,
31
+ window,
32
+ filter,
33
+ ampNamespace,
34
+ dataSourceName,
35
+ }))
36
+ .addPanel((0, success_rate_1.createSuccessRateTimeSeriesPanel)({
37
+ shortWindow,
38
+ filter,
39
+ ampNamespace,
40
+ dataSourceName,
41
+ }))
42
+ .addPanel((0, success_rate_1.createSuccessRateBurnRatePanel)({
43
+ target,
44
+ filter,
45
+ ampNamespace,
46
+ dataSourceName,
47
+ }))
48
+ .addPanel((0, latency_1.createLatencyPanel)({
49
+ target,
50
+ window,
51
+ targetLatency,
52
+ filter,
53
+ ampNamespace,
54
+ dataSourceName,
55
+ }))
56
+ .addPanel((0, latency_1.createLatencyPercentilePanel)({
57
+ target,
58
+ shortWindow,
59
+ filter,
60
+ ampNamespace,
61
+ dataSourceName,
62
+ }))
63
+ .addPanel((0, latency_1.createLatencyPercentagePanel)({
64
+ targetLatency,
65
+ shortWindow,
66
+ filter,
67
+ ampNamespace,
68
+ dataSourceName,
69
+ }))
70
+ .addPanel((0, latency_1.createLatencyBurnRatePanel)({
71
+ target,
72
+ targetLatency,
73
+ ampNamespace,
74
+ dataSourceName,
75
+ }))
76
+ .build();
77
+ }
@@ -0,0 +1,19 @@
1
+ import * as pulumi from '@pulumi/pulumi';
2
+ import * as grafana from '@pulumiverse/grafana';
3
+ import type { GrafanaDashboardBuilder } from './dashboards/builder';
4
+ import { GrafanaConnection } from './connections';
5
+ export declare namespace Grafana {
6
+ type Args = {
7
+ connectionBuilders: GrafanaConnection.CreateConnection[];
8
+ dashboardBuilders: GrafanaDashboardBuilder.CreateDashboard[];
9
+ folderName?: string;
10
+ };
11
+ }
12
+ export declare class Grafana extends pulumi.ComponentResource {
13
+ readonly name: string;
14
+ readonly connections: GrafanaConnection[];
15
+ readonly folder: grafana.oss.Folder;
16
+ readonly dashboards: grafana.oss.Dashboard[];
17
+ constructor(name: string, args: Grafana.Args, opts?: pulumi.ComponentResourceOptions);
18
+ }
19
+ //# sourceMappingURL=grafana.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grafana.d.ts","sourceRoot":"","sources":["../../../src/components/grafana/grafana.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;AACzC,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAChD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD,yBAAiB,OAAO,CAAC;IACvB,KAAY,IAAI,GAAG;QACjB,kBAAkB,EAAE,iBAAiB,CAAC,gBAAgB,EAAE,CAAC;QACzD,iBAAiB,EAAE,uBAAuB,CAAC,eAAe,EAAE,CAAC;QAC7D,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;CACH;AAED,qBAAa,OAAQ,SAAQ,MAAM,CAAC,iBAAiB;IACnD,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,WAAW,EAAE,iBAAiB,EAAE,CAAC;IACjD,SAAgB,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC;IAC3C,SAAgB,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC;gBAGlD,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,CAAC,IAAI,EAClB,IAAI,GAAE,MAAM,CAAC,wBAA6B;CAsB7C"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Grafana = void 0;
4
+ const pulumi = require("@pulumi/pulumi");
5
+ const grafana = require("@pulumiverse/grafana");
6
+ class Grafana extends pulumi.ComponentResource {
7
+ name;
8
+ connections;
9
+ folder;
10
+ dashboards;
11
+ constructor(name, args, opts = {}) {
12
+ super('studion:grafana:Grafana', name, {}, opts);
13
+ this.name = name;
14
+ this.connections = args.connectionBuilders.map(build => {
15
+ return build({ parent: this });
16
+ });
17
+ this.folder = new grafana.oss.Folder(`${this.name}-folder`, { title: args.folderName ?? `${this.name}-ICB-GENERATED` }, { parent: this });
18
+ this.dashboards = args.dashboardBuilders.map(build => {
19
+ return build(this.folder, { parent: this.folder });
20
+ });
21
+ this.registerOutputs();
22
+ }
23
+ }
24
+ exports.Grafana = Grafana;
@@ -1,2 +1,6 @@
1
1
  export * as dashboard from './dashboards';
2
+ export * as panels from './panels';
3
+ export { GrafanaConnection, AMPConnection, CloudWatchLogsConnection, XRayConnection, } from './connections';
4
+ export { Grafana } from './grafana';
5
+ export { GrafanaBuilder } from './builder';
2
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/grafana/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/grafana/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,wBAAwB,EACxB,cAAc,GACf,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC"}
@@ -1,4 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.dashboard = void 0;
3
+ exports.GrafanaBuilder = exports.Grafana = exports.XRayConnection = exports.CloudWatchLogsConnection = exports.AMPConnection = exports.GrafanaConnection = exports.panels = exports.dashboard = void 0;
4
4
  exports.dashboard = require("./dashboards");
5
+ exports.panels = require("./panels");
6
+ var connections_1 = require("./connections");
7
+ Object.defineProperty(exports, "GrafanaConnection", { enumerable: true, get: function () { return connections_1.GrafanaConnection; } });
8
+ Object.defineProperty(exports, "AMPConnection", { enumerable: true, get: function () { return connections_1.AMPConnection; } });
9
+ Object.defineProperty(exports, "CloudWatchLogsConnection", { enumerable: true, get: function () { return connections_1.CloudWatchLogsConnection; } });
10
+ Object.defineProperty(exports, "XRayConnection", { enumerable: true, get: function () { return connections_1.XRayConnection; } });
11
+ var grafana_1 = require("./grafana");
12
+ Object.defineProperty(exports, "Grafana", { enumerable: true, get: function () { return grafana_1.Grafana; } });
13
+ var builder_1 = require("./builder");
14
+ Object.defineProperty(exports, "GrafanaBuilder", { enumerable: true, get: function () { return builder_1.GrafanaBuilder; } });
@@ -0,0 +1,15 @@
1
+ import { queries as promQ } from '../../prometheus';
2
+ import { Panel } from './types';
3
+ export declare function createAvailabilityPanel(config: {
4
+ target: number;
5
+ window: promQ.TimeRange;
6
+ ampNamespace: string;
7
+ dataSourceName: string;
8
+ }): Panel;
9
+ export declare function createAvailabilityBurnRatePanel(config: {
10
+ target: number;
11
+ window: promQ.TimeRange;
12
+ ampNamespace: string;
13
+ dataSourceName: string;
14
+ }): Panel;
15
+ //# sourceMappingURL=availability.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"availability.d.ts","sourceRoot":"","sources":["../../../../src/components/grafana/panels/availability.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGhC,wBAAgB,uBAAuB,CAAC,MAAM,EAAE;IAC9C,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;CACxB,GAAG,KAAK,CAcR;AAED,wBAAgB,+BAA+B,CAAC,MAAM,EAAE;IACtD,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;CACxB,GAAG,KAAK,CAcR"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createAvailabilityPanel = createAvailabilityPanel;
4
+ exports.createAvailabilityBurnRatePanel = createAvailabilityBurnRatePanel;
5
+ const prometheus_1 = require("../../prometheus");
6
+ const helpers_1 = require("./helpers");
7
+ function createAvailabilityPanel(config) {
8
+ return (0, helpers_1.createStatPercentagePanel)('Availability', { x: 0, y: 0, w: 8, h: 8 }, config.dataSourceName, {
9
+ label: 'Availability',
10
+ query: prometheus_1.queries.getAvailabilityPercentageQuery(config.ampNamespace, config.window),
11
+ thresholds: [],
12
+ });
13
+ }
14
+ function createAvailabilityBurnRatePanel(config) {
15
+ return (0, helpers_1.createBurnRatePanel)('Availability Burn Rate', { x: 0, y: 8, w: 8, h: 4 }, config.dataSourceName, {
16
+ label: 'Burn Rate',
17
+ query: prometheus_1.queries.getBurnRateQuery(prometheus_1.queries.getAvailabilityQuery(config.ampNamespace, '1h'), config.target),
18
+ thresholds: [],
19
+ });
20
+ }
@@ -0,0 +1,6 @@
1
+ import { Panel, Metric } from './types';
2
+ export declare function createStatPercentagePanel(title: string, position: Panel.Position, dataSource: string, metric: Metric): Panel;
3
+ export declare function createTimeSeriesPercentagePanel(title: string, position: Panel.Position, dataSource: string, metric: Metric): Panel;
4
+ export declare function createTimeSeriesPanel(title: string, position: Panel.Position, dataSource: string, metric: Metric, unit?: string, min?: number, max?: number): Panel;
5
+ export declare function createBurnRatePanel(title: string, position: Panel.Position, dataSource: string, metric: Metric): Panel;
6
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../src/components/grafana/panels/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAQxC,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,GACb,KAAK,CA0BP;AAED,wBAAgB,+BAA+B,CAC7C,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,GACb,KAAK,CAUP;AAED,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,IAAI,CAAC,EAAE,MAAM,EACb,GAAG,CAAC,EAAE,MAAM,EACZ,GAAG,CAAC,EAAE,MAAM,GACX,KAAK,CA4BP;AAED,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,GACb,KAAK,CAoCP"}
@@ -0,0 +1,6 @@
1
+ export * from './types';
2
+ export * from './helpers';
3
+ export * from './availability';
4
+ export * from './success-rate';
5
+ export * from './latency';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/grafana/panels/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC"}