UNPKG

@pulumi/sumologic

Version:

A Pulumi package for creating and managing sumologic cloud resources.

385 lines 15.8 kB
"use strict"; // *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.Monitor = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("./utilities"); /** * Provides the ability to create, read, delete, and update [Monitors](https://help.sumologic.com/?cid=10020). * If Fine Grain Permission (FGP) feature is enabled with Monitors Content at one's Sumo Logic account, one can also set those permission details under this monitor resource. For further details about FGP, please see this [Monitor Permission document](https://help.sumologic.com/Visualizations-and-Alerts/Alerts/Monitors#configure-permissions-for-a-monitor). * * ## Example SLO Monitors * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as sumologic from "@pulumi/sumologic"; * * const tfSloMonitor1 = new sumologic.Monitor("tf_slo_monitor_1", { * name: "SLO SLI monitor", * type: "MonitorsLibraryMonitor", * isDisabled: false, * contentType: "Monitor", * monitorType: "Slo", * sloId: "0000000000000009", * evaluationDelay: "5m", * tags: { * team: "monitoring", * application: "sumologic", * }, * triggerConditions: { * sloSliCondition: { * critical: { * sliThreshold: 99.5, * }, * warning: { * sliThreshold: 99.9, * }, * }, * }, * notifications: [{ * notification: { * connectionType: "Email", * recipients: ["abc@example.com"], * subject: "Monitor Alert: {{TriggerType}} on {{Name}}", * timeZone: "PST", * messageBody: "Triggered {{TriggerType}} Alert on {{Name}}: {{QueryURL}}", * }, * runForTriggerTypes: [ * "Critical", * "ResolvedCritical", * ], * }], * playbook: "test playbook", * }); * const tfSloMonitor2 = new sumologic.Monitor("tf_slo_monitor_2", { * name: "SLO Burn rate monitor", * type: "MonitorsLibraryMonitor", * isDisabled: false, * contentType: "Monitor", * monitorType: "Slo", * sloId: "0000000000000009", * evaluationDelay: "5m", * tags: { * team: "monitoring", * application: "sumologic", * }, * triggerConditions: { * sloBurnRateCondition: { * critical: { * burnRates: [{ * burnRateThreshold: 50, * timeRange: "1d", * }], * }, * warning: { * burnRates: [ * { * burnRateThreshold: 30, * timeRange: "3d", * }, * { * burnRateThreshold: 20, * timeRange: "4d", * }, * ], * }, * }, * }, * }); * ``` * * ## Example Logs Anomaly Monitor * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as sumologic from "@pulumi/sumologic"; * * const tfExampleAnomalyMonitor = new sumologic.Monitor("tf_example_anomaly_monitor", { * name: "Example Anomaly Monitor", * description: "example anomaly monitor", * type: "MonitorsLibraryMonitor", * monitorType: "Logs", * isDisabled: false, * queries: [{ * rowId: "A", * query: "_sourceCategory=api error | timeslice 5m | count by _sourceHost", * }], * triggerConditions: { * logsAnomalyCondition: { * field: "_count", * anomalyDetectorType: "Cluster", * critical: { * sensitivity: 0.4, * minAnomalyCount: 9, * timeRange: "-3h", * }, * }, * }, * notifications: [{ * notification: { * connectionType: "Email", * recipients: ["anomaly@example.com"], * subject: "Monitor Alert: {{TriggerType}} on {{Name}}", * timeZone: "PST", * messageBody: "Triggered {{TriggerType}} Alert on {{Name}}: {{QueryURL}}", * }, * runForTriggerTypes: [ * "Critical", * "ResolvedCritical", * ], * }], * }); * ``` * * ## Example Metrics Anomaly Monitor * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as sumologic from "@pulumi/sumologic"; * * const tfExampleMetricsAnomalyMonitor = new sumologic.Monitor("tf_example_metrics_anomaly_monitor", { * name: "Example Metrics Anomaly Monitor", * description: "example metrics anomaly monitor", * type: "MonitorsLibraryMonitor", * monitorType: "Metrics", * isDisabled: false, * queries: [{ * rowId: "A", * query: "service=auth api=login metric=HTTP_5XX_Count | avg", * }], * triggerConditions: { * metricsAnomalyCondition: { * anomalyDetectorType: "Cluster", * critical: { * sensitivity: 0.4, * minAnomalyCount: 9, * timeRange: "-3h", * }, * }, * }, * notifications: [{ * notification: { * connectionType: "Email", * recipients: ["anomaly@example.com"], * subject: "Monitor Alert: {{TriggerType}} on {{Name}}", * timeZone: "PST", * messageBody: "Triggered {{TriggerType}} Alert on {{Name}}: {{QueryURL}}", * }, * runForTriggerTypes: [ * "Critical", * "ResolvedCritical", * ], * }], * }); * ``` * * ## Monitor Folders * * <<<<<<< HEAD * NOTE: Monitor folders are considered a different resource from Library content folders. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as sumologic from "@pulumi/sumologic"; * * const tfMonitorFolder1 = new sumologic.MonitorFolder("tf_monitor_folder_1", { * name: "test folder", * description: "a folder for monitors", * }); * ``` * ======= * NOTE: Monitor folders are considered a different resource from Library content folders. See [sumologic.MonitorFolder][2] for more details. * > > > > > > > v2.11.0 * * ## The `triggerConditions` block * * A `triggerConditions` block configures conditions for sending notifications. * ## The `triggers` block * * The `triggers` block is deprecated. Please use `triggerConditions` to specify notification conditions. * * Here's an example logs monitor that uses `triggers` to specify trigger conditions: * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as sumologic from "@pulumi/sumologic"; * * const tfLogsMonitor1 = new sumologic.Monitor("tf_logs_monitor_1", { * name: "Terraform Logs Monitor", * description: "tf logs monitor", * type: "MonitorsLibraryMonitor", * isDisabled: false, * contentType: "Monitor", * monitorType: "Logs", * queries: [{ * rowId: "A", * query: "_sourceCategory=event-action info", * }], * triggers: [ * { * thresholdType: "GreaterThan", * threshold: 40, * timeRange: "15m", * occurrenceType: "ResultCount", * triggerSource: "AllResults", * triggerType: "Critical", * detectionMethod: "StaticCondition", * }, * { * thresholdType: "LessThanOrEqual", * threshold: 40, * timeRange: "15m", * occurrenceType: "ResultCount", * triggerSource: "AllResults", * triggerType: "ResolvedCritical", * detectionMethod: "StaticCondition", * resolutionWindow: "5m", * }, * ], * notifications: [ * { * notification: { * connectionType: "Email", * recipients: ["abc@example.com"], * subject: "Monitor Alert: {{TriggerType}} on {{Name}}", * timeZone: "PST", * messageBody: "Triggered {{TriggerType}} Alert on {{Name}}: {{QueryURL}}", * }, * runForTriggerTypes: [ * "Critical", * "ResolvedCritical", * ], * }, * { * notification: { * connectionType: "Webhook", * connectionId: "0000000000ABC123", * }, * runForTriggerTypes: [ * "Critical", * "ResolvedCritical", * ], * }, * ], * }); * ``` * * ## Import * * Monitors can be imported using the monitor ID, such as: * * hcl * * ```sh * $ pulumi import sumologic:index/monitor:Monitor test 1234567890 * ``` * * [1]: https://help.sumologic.com/?cid=10020 * * [2]: monitor_folder.html.markdown * * [3]: https://help.sumologic.com/Visualizations-and-Alerts/Alerts/Monitors#configure-permissions-for-a-monitor */ class Monitor extends pulumi.CustomResource { /** * Get an existing Monitor 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 Monitor(name, state, Object.assign(Object.assign({}, opts), { id: id })); } /** * Returns true if the given object is an instance of Monitor. 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'] === Monitor.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["alertName"] = state ? state.alertName : undefined; resourceInputs["contentType"] = state ? state.contentType : undefined; resourceInputs["createdAt"] = state ? state.createdAt : undefined; resourceInputs["createdBy"] = state ? state.createdBy : undefined; resourceInputs["description"] = state ? state.description : undefined; resourceInputs["evaluationDelay"] = state ? state.evaluationDelay : undefined; resourceInputs["groupNotifications"] = state ? state.groupNotifications : undefined; resourceInputs["isDisabled"] = state ? state.isDisabled : undefined; resourceInputs["isLocked"] = state ? state.isLocked : undefined; resourceInputs["isMutable"] = state ? state.isMutable : undefined; resourceInputs["isSystem"] = state ? state.isSystem : undefined; resourceInputs["modifiedAt"] = state ? state.modifiedAt : undefined; resourceInputs["modifiedBy"] = state ? state.modifiedBy : undefined; resourceInputs["monitorType"] = state ? state.monitorType : undefined; resourceInputs["name"] = state ? state.name : undefined; resourceInputs["notificationGroupFields"] = state ? state.notificationGroupFields : undefined; resourceInputs["notifications"] = state ? state.notifications : undefined; resourceInputs["objPermissions"] = state ? state.objPermissions : undefined; resourceInputs["parentId"] = state ? state.parentId : undefined; resourceInputs["playbook"] = state ? state.playbook : undefined; resourceInputs["postRequestMap"] = state ? state.postRequestMap : undefined; resourceInputs["queries"] = state ? state.queries : undefined; resourceInputs["sloId"] = state ? state.sloId : undefined; resourceInputs["statuses"] = state ? state.statuses : undefined; resourceInputs["tags"] = state ? state.tags : undefined; resourceInputs["timeZone"] = state ? state.timeZone : undefined; resourceInputs["triggerConditions"] = state ? state.triggerConditions : undefined; resourceInputs["triggers"] = state ? state.triggers : undefined; resourceInputs["type"] = state ? state.type : undefined; resourceInputs["version"] = state ? state.version : undefined; } else { const args = argsOrState; if ((!args || args.monitorType === undefined) && !opts.urn) { throw new Error("Missing required property 'monitorType'"); } resourceInputs["alertName"] = args ? args.alertName : undefined; resourceInputs["contentType"] = args ? args.contentType : undefined; resourceInputs["createdAt"] = args ? args.createdAt : undefined; resourceInputs["createdBy"] = args ? args.createdBy : undefined; resourceInputs["description"] = args ? args.description : undefined; resourceInputs["evaluationDelay"] = args ? args.evaluationDelay : undefined; resourceInputs["groupNotifications"] = args ? args.groupNotifications : undefined; resourceInputs["isDisabled"] = args ? args.isDisabled : undefined; resourceInputs["isLocked"] = args ? args.isLocked : undefined; resourceInputs["isMutable"] = args ? args.isMutable : undefined; resourceInputs["isSystem"] = args ? args.isSystem : undefined; resourceInputs["modifiedAt"] = args ? args.modifiedAt : undefined; resourceInputs["modifiedBy"] = args ? args.modifiedBy : undefined; resourceInputs["monitorType"] = args ? args.monitorType : undefined; resourceInputs["name"] = args ? args.name : undefined; resourceInputs["notificationGroupFields"] = args ? args.notificationGroupFields : undefined; resourceInputs["notifications"] = args ? args.notifications : undefined; resourceInputs["objPermissions"] = args ? args.objPermissions : undefined; resourceInputs["parentId"] = args ? args.parentId : undefined; resourceInputs["playbook"] = args ? args.playbook : undefined; resourceInputs["postRequestMap"] = args ? args.postRequestMap : undefined; resourceInputs["queries"] = args ? args.queries : undefined; resourceInputs["sloId"] = args ? args.sloId : undefined; resourceInputs["tags"] = args ? args.tags : undefined; resourceInputs["timeZone"] = args ? args.timeZone : undefined; resourceInputs["triggerConditions"] = args ? args.triggerConditions : undefined; resourceInputs["triggers"] = args ? args.triggers : undefined; resourceInputs["type"] = args ? args.type : undefined; resourceInputs["version"] = args ? args.version : undefined; resourceInputs["statuses"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(Monitor.__pulumiType, name, resourceInputs, opts); } } exports.Monitor = Monitor; /** @internal */ Monitor.__pulumiType = 'sumologic:index/monitor:Monitor'; //# sourceMappingURL=monitor.js.map