@pulumi/harness
Version:
A Pulumi package for creating and managing Harness resources.
922 lines • 38.2 kB
JavaScript
"use strict";
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.MonitoredService = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* Resource for creating a monitored service.
*
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as harness from "@pulumi/harness";
*
* //Sample template for Elastic Search Log Health Source
* const example = new harness.platform.MonitoredService("example", {
* orgId: "org_id",
* projectId: "project_id",
* identifier: "identifier",
* request: {
* name: "name",
* type: "Application",
* description: "description",
* serviceRef: "service_ref",
* environmentRef: "environment_ref",
* tags: [
* "foo:bar",
* "bar:foo",
* ],
* healthSources: [{
* name: "name",
* identifier: "identifier",
* type: "ElasticSearch",
* version: "v2",
* spec: JSON.stringify({
* connectorRef: "connectorRef",
* queryDefinitions: [
* {
* name: "name",
* identifier: "infraquery",
* query: "query",
* index: "index",
* groupName: "Logs_Group",
* queryParams: {
* index: "index",
* serviceInstanceField: "serviceInstanceIdentifier",
* timeStampIdentifier: "timeStampIdentifier",
* timeStampFormat: "timeStampFormat",
* messageIdentifier: "messageIdentifier",
* },
* },
* {
* name: "name2",
* identifier: "errorquery",
* query: "query2",
* index: "index2",
* groupName: "Logs_Group",
* queryParams: {
* index: "index",
* serviceInstanceField: "serviceInstanceIdentifier",
* timeStampIdentifier: "timeStampIdentifier",
* timeStampFormat: "timeStampFormat",
* messageIdentifier: "messageIdentifier",
* },
* },
* ],
* }),
* }],
* changeSources: [
* {
* name: "BAC",
* identifier: "BAC",
* type: "PagerDuty",
* enabled: true,
* spec: JSON.stringify({
* connectorRef: "account.pd",
* pagerDutyServiceId: "P0N21OB",
* }),
* category: "Alert",
* },
* {
* name: "FH",
* identifier: "FH",
* type: "CustomIncident",
* enabled: true,
* spec: JSON.stringify({
* name: "FH",
* webhookUrl: "https://harness.io/cv/api/account/sampleAcc/org/sampleOrg/project/sampleProj/webhook/custom-change?monitoredServiceIdentifier=checkout_prod&changeSourceIdentifier=FH",
* webhookCurlCommand: "curl -X POST -H 'content-type: application/json' -H 'X-Api-Key: sample_api_key' --url 'https://harness.io/cv/api/account/sampleAcc/org/sampleOrg/project/sampleProj/webhook/custom-change?monitoredServiceIdentifier=checkout_prod&changeSourceIdentifier=FH' -d '{ \"eventIdentifier\": \"<string>\" (optional), \"user\": \"user@harness.io\", \"startTime\": timeInMs, \"endTime\": timeInMs, \"eventDetail\": { \"description\": \"<String>\", \"changeEventDetailsLink\": \"urlString\" (optional), \"externalLinkToEntity\": \"urlString\" (optional), \"name\": \"changeEventName\" } }'",
* type: "Alert",
* }),
* category: "Alert",
* },
* {
* name: "customff",
* identifier: "customff",
* type: "CustomFF",
* enabled: true,
* category: "FeatureFlag",
* spec: JSON.stringify({
* type: "FeatureFlag",
* }),
* },
* {
* name: "customdeploy",
* identifier: "customdeploy",
* type: "CustomDeploy",
* enabled: true,
* category: "Deployment",
* spec: JSON.stringify({
* type: "Deployment",
* }),
* },
* {
* name: "customincident",
* identifier: "customincident",
* type: "CustomIncident",
* enabled: true,
* category: "Alert",
* spec: JSON.stringify({
* type: "Alert",
* authorizationToken: "abc",
* }),
* },
* ],
* notificationRuleRefs: [
* {
* notificationRuleRef: "notification_rule_ref",
* enabled: true,
* },
* {
* notificationRuleRef: "notification_rule_ref1",
* enabled: false,
* },
* ],
* },
* });
* //Sample template for Sumologic Metrics Health Source
* const example1 = new harness.platform.MonitoredService("example1", {
* orgId: "org_id",
* projectId: "project_id",
* identifier: "identifier",
* request: {
* name: "name",
* type: "Application",
* description: "description",
* serviceRef: "service_ref",
* environmentRef: "environment_ref",
* tags: [
* "foo:bar",
* "bar:foo",
* ],
* healthSources: [{
* name: "sumologicmetrics",
* identifier: "sumo_metric_identifier",
* type: "SumologicMetrics",
* version: "v2",
* spec: JSON.stringify({
* connectorRef: "connectorRef",
* queryDefinitions: [
* {
* name: "metric_cpu",
* identifier: "metric_cpu",
* query: "metric=cpu",
* groupName: "g1",
* queryParams: {
* serviceInstanceField: "_sourcehost",
* },
* riskProfile: {
* riskCategory: "Performance_Other",
* thresholdTypes: ["ACT_WHEN_HIGHER"],
* },
* liveMonitoringEnabled: "true",
* continuousVerificationEnabled: "true",
* sliEnabled: "false",
* metricThresholds: [
* {
* type: "IgnoreThreshold",
* spec: {
* action: "Ignore",
* },
* criteria: {
* type: "Absolute",
* spec: {
* greaterThan: 100,
* },
* },
* metricType: "Custom",
* metricName: "metric_cpu",
* },
* {
* type: "FailImmediately",
* spec: {
* action: "FailAfterOccurrence",
* spec: {
* count: 2,
* },
* },
* criteria: {
* type: "Absolute",
* spec: {
* greaterThan: 100,
* },
* },
* metricType: "Custom",
* metricName: "metric_cpu",
* },
* ],
* },
* {
* name: "name2",
* identifier: "identifier2",
* groupName: "g2",
* query: "metric=memory",
* queryParams: {
* serviceInstanceField: "_sourcehost",
* },
* riskProfile: {
* riskCategory: "Performance_Other",
* thresholdTypes: ["ACT_WHEN_HIGHER"],
* },
* liveMonitoringEnabled: "false",
* continuousVerificationEnabled: "false",
* sliEnabled: "false",
* },
* ],
* }),
* }],
* },
* });
* //Sample template for Sumologic Log Health Source
* const example2 = new harness.platform.MonitoredService("example2", {
* orgId: "org_id",
* projectId: "project_id",
* identifier: "identifier",
* request: {
* name: "name",
* type: "Application",
* description: "description",
* serviceRef: "service_ref",
* environmentRef: "environment_ref",
* tags: [
* "foo:bar",
* "bar:foo",
* ],
* healthSources: [{
* name: "sumologic",
* identifier: "sumo_metric_identifier",
* type: "SumologicLogs",
* version: "v2",
* spec: JSON.stringify({
* connectorRef: "connectorRef",
* queryDefinitions: [
* {
* name: "log1",
* identifier: "log1",
* query: "*",
* groupName: "Logs Group",
* queryParams: {
* serviceInstanceField: "_sourcehost",
* },
* },
* {
* name: "log2",
* identifier: "identifier2",
* groupName: "g2",
* query: "error",
* queryParams: {
* serviceInstanceField: "_sourcehost",
* },
* },
* ],
* }),
* }],
* },
* });
* //Sample template for Splunk Signal FX Health Source
* const example3 = new harness.platform.MonitoredService("example3", {
* orgId: "org_id",
* projectId: "project_id",
* identifier: "identifier",
* request: {
* name: "name",
* type: "Application",
* description: "description",
* serviceRef: "service_ref",
* environmentRef: "environment_ref",
* tags: [
* "foo:bar",
* "bar:foo",
* ],
* healthSources: [{
* name: "signalfxmetrics",
* identifier: "signalfxmetrics",
* type: "SplunkSignalFXMetrics",
* version: "v2",
* spec: JSON.stringify({
* connectorRef: "connectorRef",
* queryDefinitions: [
* {
* name: "metric_infra_cpu",
* identifier: "metric_infra_cpu",
* query: "***",
* groupName: "g",
* riskProfile: {
* riskCategory: "Errors",
* thresholdTypes: [
* "ACT_WHEN_HIGHER",
* "ACT_WHEN_LOWER",
* ],
* },
* liveMonitoringEnabled: "true",
* continuousVerificationEnabled: "true",
* sliEnabled: "false",
* },
* {
* name: "name2",
* identifier: "identifier2",
* groupName: "g2",
* query: "*",
* riskProfile: {
* riskCategory: "Performance_Other",
* thresholdTypes: ["ACT_WHEN_HIGHER"],
* },
* liveMonitoringEnabled: "true",
* continuousVerificationEnabled: "false",
* sliEnabled: "false",
* metricThresholds: [
* {
* type: "IgnoreThreshold",
* spec: {
* action: "Ignore",
* },
* criteria: {
* type: "Absolute",
* spec: {
* greaterThan: 100,
* },
* },
* metrictype: "Custom",
* metricName: "identifier2",
* },
* {
* type: "FailImmediately",
* spec: {
* action: "FailAfterOccurrence",
* spec: {
* count: 2,
* },
* },
* criteria: {
* type: "Absolute",
* spec: {
* greaterThan: 100,
* },
* },
* metricType: "Custom",
* metricName: "identifier2",
* },
* ],
* },
* ],
* }),
* }],
* },
* });
* //Sample template for Grafana Loki Log Health Source
* const example4 = new harness.platform.MonitoredService("example4", {
* orgId: "org_id",
* projectId: "project_id",
* identifier: "identifier",
* request: {
* name: "name",
* type: "Application",
* description: "description",
* serviceRef: "service_ref",
* environmentRef: "environment_ref",
* tags: [
* "foo:bar",
* "bar:foo",
* ],
* healthSources: [{
* name: "Test",
* identifier: "Test",
* type: "GrafanaLokiLogs",
* version: "v2",
* spec: JSON.stringify({
* connectorRef: "connectorRef",
* queryDefinitions: [
* {
* name: "Demo",
* identifier: "Demo",
* query: "{job=~\".+\"}",
* groupName: "Log_Group",
* queryParams: {
* serviceInstanceField: "job",
* },
* },
* {
* name: "log2",
* identifier: "identifier2",
* groupName: "g2",
* query: "error",
* queryParams: {
* serviceInstanceField: "_sourcehost",
* },
* liveMonitoringEnabled: "false",
* continuousVerificationEnabled: "false",
* sliEnabled: "false",
* },
* ],
* }),
* }],
* },
* });
* //Sample template for Azure Metrics Health Source
* const example5 = new harness.platform.MonitoredService("example5", {
* orgId: "org_id",
* projectId: "project_id",
* identifier: "identifier",
* request: {
* name: "name",
* type: "Application",
* description: "description",
* serviceRef: "service_ref",
* environmentRef: "environment_ref",
* tags: [
* "foo:bar",
* "bar:foo",
* ],
* healthSources: [{
* name: "azure metrics verify step",
* identifier: "azure_metrics_verify_step",
* type: "AzureMetrics",
* version: "v2",
* spec: JSON.stringify({
* connectorRef: "connectorRef",
* queryDefinitions: [
* {
* name: "metric",
* identifier: "metric",
* query: "default",
* groupName: "g1",
* queryParams: {
* serviceInstanceField: "host",
* index: "/subscriptions/12d2db62-5aa9-471d-84bb-faa489b3e319/resourceGroups/srm-test/providers/Microsoft.ContainerService/managedClusters/srm-test",
* healthSourceMetricName: "cpuUsagePercentage",
* healthSourceMetricNamespace: "insights.container/nodes",
* aggregationType: "average",
* },
* riskProfile: {
* riskCategory: "Performance_Other",
* thresholdTypes: ["ACT_WHEN_HIGHER"],
* },
* liveMonitoringEnabled: "true",
* continuousVerificationEnabled: "true",
* sliEnabled: "false",
* metricThresholds: [
* {
* type: "IgnoreThreshold",
* spec: {
* action: "Ignore",
* },
* criteria: {
* type: "Absolute",
* spec: {
* greaterThan: 100,
* },
* },
* metrictype: "Custom",
* metricName: "metric",
* },
* {
* type: "FailImmediately",
* spec: {
* action: "FailAfterOccurrence",
* spec: {
* count: 2,
* },
* },
* criteria: {
* type: "Absolute",
* spec: {
* greaterThan: 100,
* },
* },
* metricType: "Custom",
* metricName: "metric",
* },
* ],
* },
* {
* name: "name2",
* identifier: "identifier2",
* groupName: "g2",
* queryParams: {
* serviceInstanceField: "host",
* index: "/subscriptions/12d2db62-5aa9-471d-84bb-faa489b3e319/resourceGroups/srm-test/providers/Microsoft.ContainerService/managedClusters/srm-test",
* healthSourceMetricName: "cpuUsagePercentage",
* healthSourceMetricNamespace: "insights.container/nodes",
* aggregationType: "average",
* },
* riskProfile: {
* riskCategory: "Performance_Other",
* thresholdTypes: ["ACT_WHEN_HIGHER"],
* },
* liveMonitoringEnabled: "false",
* continuousVerificationEnabled: "false",
* sliEnabled: "false",
* },
* ],
* }),
* }],
* },
* });
* //Sample template for Azure Log Health Source
* const example6 = new harness.platform.MonitoredService("example6", {
* orgId: "org_id",
* projectId: "project_id",
* identifier: "identifier",
* request: {
* name: "name",
* type: "Application",
* description: "description",
* serviceRef: "service_ref",
* environmentRef: "environment_ref",
* tags: [
* "foo:bar",
* "bar:foo",
* ],
* healthSources: [{
* name: "Demo azure",
* identifier: "Demo_azure",
* type: "AzureLogs",
* version: "v2",
* spec: JSON.stringify({
* connectorRef: "connectorRef",
* queryDefinitions: [{
* name: "name2",
* identifier: "identifier2",
* groupName: "g2",
* query: "*",
* queryParams: {
* serviceInstanceField: "Name",
* timeStampIdentifier: "StartedTime",
* messageIdentifier: "Image",
* index: "/subscriptions/12d2db62-5aa9-471d-84bb-faa489b3e319/resourceGroups/srm-test/providers/Microsoft.ContainerService/managedClusters/srm-test",
* },
* liveMonitoringEnabled: "false",
* continuousVerificationEnabled: "false",
* }],
* }),
* }],
* },
* });
* //Sample template for Prometheus Metrics Health Source
* const example7 = new harness.platform.MonitoredService("example7", {
* orgId: "org_id",
* projectId: "project_id",
* identifier: "identifier",
* request: {
* name: "name",
* type: "Application",
* description: "description",
* serviceRef: "service_ref",
* environmentRef: "environment_ref",
* tags: [
* "foo:bar",
* "bar:foo",
* ],
* healthSources: [{
* name: "prometheus metrics verify step",
* identifier: "prometheus_metrics",
* type: "Prometheus",
* spec: JSON.stringify({
* connectorRef: "connectorRef",
* metricDefinitions: [{
* identifier: "Prometheus_Metric",
* metricName: "Prometheus Metric",
* riskProfile: {
* riskCategory: "Performance_Other",
* thresholdTypes: ["ACT_WHEN_HIGHER"],
* },
* analysis: {
* liveMonitoring: {
* enabled: true,
* },
* deploymentVerification: {
* enabled: true,
* serviceInstanceFieldName: "pod_name",
* },
* },
* query: "count(up{group=\"cv\",group=\"cv\"})",
* groupName: "met",
* isManualQuery: true,
* }],
* metricPacks: [{
* identifier: "Custom",
* metricThresholds: [
* {
* type: "IgnoreThreshold",
* spec: {
* action: "Ignore",
* },
* criteria: {
* type: "Absolute",
* spec: {
* greaterThan: 100,
* },
* },
* metrictype: "Custom",
* metricName: "Prometheus Metric",
* },
* {
* type: "FailImmediately",
* spec: {
* action: "FailAfterOccurrence",
* spec: {
* count: 2,
* },
* },
* criteria: {
* type: "Absolute",
* spec: {
* greaterThan: 100,
* },
* },
* metricType: "Custom",
* metricName: "Prometheus Metric",
* },
* ],
* }],
* }),
* }],
* },
* });
* //Sample template for Datadog Metrics Health Source
* const example8 = new harness.platform.MonitoredService("example8", {
* orgId: "org_id",
* projectId: "project_id",
* identifier: "identifier",
* request: {
* name: "name",
* type: "Application",
* description: "description",
* serviceRef: "service_ref",
* environmentRef: "environment_ref",
* tags: [
* "foo:bar",
* "bar:foo",
* ],
* healthSources: [{
* name: "ddm",
* identifier: "ddm",
* type: "DatadogMetrics",
* spec: JSON.stringify({
* connectorRef: "connectorRef",
* feature: "Datadog Cloud Metrics",
* metricDefinitions: [
* {
* metricName: "metric",
* metricPath: "M1",
* identifier: "metric",
* query: `avg:kubernetes.cpu.limits{*}.rollup(avg, 60);
* avg:kubernetes.cpu.limits{*}.rollup(avg, 30);
* (a+b)/10`,
* isManualQuery: true,
* isCustomCreatedMetric: true,
* riskProfile: {
* riskCategory: "Performance_Other",
* thresholdTypes: ["ACT_WHEN_HIGHER"],
* },
* analysis: {
* liveMonitoring: {
* enabled: true,
* },
* deploymentVerification: {
* enabled: true,
* serviceInstanceFieldName: "pod",
* },
* },
* },
* {
* metricName: "dashboard_metric_cpu",
* identifier: "metric_cpu",
* query: `avg:kubernetes.cpu.limits{*}.rollup(avg, 60);
* avg:kubernetes.cpu.limits{*}.rollup(avg, 30);
* (a+b)/10`,
* isManualQuery: false,
* dashboardName: "dashboard",
* metricPath: "M1",
* groupingQuery: "avg:kubernetes.cpu.limits{*} by {host}.rollup(avg, 60)",
* metric: "kubernetes.cpu.limits",
* aggregation: "avg",
* isCustomCreatedMetric: true,
* riskProfile: {
* riskCategory: "Performance_Other",
* thresholdTypes: ["ACT_WHEN_HIGHER"],
* },
* analysis: {
* liveMonitoring: {
* enabled: true,
* },
* deploymentVerification: {
* enabled: true,
* serviceInstanceFieldName: "pod",
* },
* },
* },
* ],
* metricPacks: [{
* identifier: "Custom",
* metricThresholds: [
* {
* type: "IgnoreThreshold",
* spec: {
* action: "Ignore",
* },
* criteria: {
* type: "Absolute",
* spec: {
* greaterThan: 100,
* },
* },
* metrictype: "Custom",
* metricName: "metric",
* },
* {
* type: "FailImmediately",
* spec: {
* action: "FailAfterOccurrence",
* spec: {
* count: 2,
* },
* },
* criteria: {
* type: "Absolute",
* spec: {
* greaterThan: 100,
* },
* },
* metricType: "Custom",
* metricName: "metric",
* },
* ],
* }],
* }),
* }],
* },
* });
* //Sample template for New Relic Metrics Health Source
* const example9 = new harness.platform.MonitoredService("example9", {
* orgId: "org_id",
* projectId: "project_id",
* identifier: "identifier",
* request: {
* name: "name",
* type: "Application",
* description: "description",
* serviceRef: "service_ref",
* environmentRef: "environment_ref",
* tags: [
* "foo:bar",
* "bar:foo",
* ],
* healthSources: [{
* name: "name",
* identifier: "identifier",
* type: "NewRelic",
* spec: JSON.stringify({
* connectorRef: "account.Newrelicautomation_do_not_delete",
* feature: "apm",
* applicationId: "107019083",
* applicationName: "My Application",
* metricData: {
* Performance: true,
* },
* metricPacks: [{
* identifier: "Performance",
* }],
* newRelicMetricDefinitions: [{
* identifier: "New_Relic_Metric",
* metricName: "New Relic Metric",
* riskProfile: {
* riskCategory: "Performance_Other",
* thresholdTypes: ["ACT_WHEN_HIGHER"],
* },
* analysis: {
* deploymentVerification: {
* enabled: true,
* },
* },
* groupName: "group1",
* nrql: "SELECT count(apm.service.instance.count) FROM Metric WHERE appName LIKE 'My Application' TIMESERIES",
* responseMapping: {
* metricValueJsonPath: "$.['timeSeries'].[*].['results'].[*].['count']",
* timestampJsonPath: "$.['timeSeries'].[*].['beginTimeSeconds']",
* },
* }],
* metricPacks: [{
* identifier: "Custom",
* metricThresholds: [
* {
* type: "IgnoreThreshold",
* spec: {
* action: "Ignore",
* },
* criteria: {
* type: "Absolute",
* spec: {
* greaterThan: 100,
* },
* },
* metricType: "Custom",
* metricName: "New Relic Metric",
* },
* {
* type: "FailImmediately",
* spec: {
* action: "FailAfterOccurrence",
* spec: {
* count: 2,
* },
* },
* criteria: {
* type: "Absolute",
* spec: {
* greaterThan: 100,
* },
* },
* metricType: "Custom",
* metricName: "New Relic Metric",
* },
* ],
* }],
* }),
* }],
* },
* });
* ```
*
* ## Import
*
* The `pulumi import` command can be used, for example:
*
* Import account level monitored_service
*
* ```sh
* $ pulumi import harness:platform/monitoredService:MonitoredService example <monitored_service_id>
* ```
*
* Import organization level monitored_service
*
* ```sh
* $ pulumi import harness:platform/monitoredService:MonitoredService example <org_id>/<monitored_service_id>
* ```
*
* Import project level monitored_service
*
* ```sh
* $ pulumi import harness:platform/monitoredService:MonitoredService example <org_id>/<project_id>/<monitored_service_id>
* ```
*/
class MonitoredService extends pulumi.CustomResource {
/**
* Get an existing MonitoredService resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state Any extra arguments used during the lookup.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
static get(name, id, state, opts) {
return new MonitoredService(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of MonitoredService. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
static isInstance(obj) {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === MonitoredService.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["identifier"] = state?.identifier;
resourceInputs["orgId"] = state?.orgId;
resourceInputs["projectId"] = state?.projectId;
resourceInputs["request"] = state?.request;
}
else {
const args = argsOrState;
if (args?.identifier === undefined && !opts.urn) {
throw new Error("Missing required property 'identifier'");
}
if (args?.orgId === undefined && !opts.urn) {
throw new Error("Missing required property 'orgId'");
}
if (args?.projectId === undefined && !opts.urn) {
throw new Error("Missing required property 'projectId'");
}
resourceInputs["identifier"] = args?.identifier;
resourceInputs["orgId"] = args?.orgId;
resourceInputs["projectId"] = args?.projectId;
resourceInputs["request"] = args?.request;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(MonitoredService.__pulumiType, name, resourceInputs, opts);
}
}
exports.MonitoredService = MonitoredService;
/** @internal */
MonitoredService.__pulumiType = 'harness:platform/monitoredService:MonitoredService';
//# sourceMappingURL=monitoredService.js.map