@pulumi/signalfx
Version:
A Pulumi package for creating and managing SignalFx resources.
199 lines • 10.1 kB
JavaScript
;
// *** 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.Detector = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("./utilities");
/**
* Provides a Splunk Observability Cloud detector resource. This can be used to create and manage detectors.
*
* If you're interested in using Splunk Observability Cloud detector features such as Historical Anomaly, Resource Running Out, or others, consider building them in the UI first and then use the "Show SignalFlow" feature to extract the value for `programText`. You can also see the [documentation for detector functions in signalflow-library](https://github.com/signalfx/signalflow-library/tree/master/library/signalfx/detectors).
*
* > **NOTE** When you want to change or remove write permissions for a user other than yourself regarding detectors, use a session token of an administrator to authenticate the Splunk Observability Cloud provider. See [Operations that require a session token for an administrator](https://dev.splunk.com/observability/docs/administration/authtokens#Operations-that-require-a-session-token-for-an-administrator).
*
* ## Example
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as signalfx from "@pulumi/signalfx";
*
* const config = new pulumi.Config();
* const clusters = config.getObject<any>("clusters") || [
* "clusterA",
* "clusterB",
* ];
* const applicationDelay: signalfx.Detector[] = [];
* for (const range = {value: 0}; range.value < clusters.length; range.value++) {
* applicationDelay.push(new signalfx.Detector(`application_delay-${range.value}`, {
* name: ` max average delay - ${clusters[range.value]}`,
* description: `your application is slow - ${clusters[range.value]}`,
* maxDelay: 30,
* tags: [
* "app-backend",
* "staging",
* ],
* authorizedWriterTeams: [mycoolteam.id],
* authorizedWriterUsers: ["abc123"],
* programText: `signal = data('app.delay', filter('cluster','${clusters[range.value]}'), extrapolation='last_value', maxExtrapolations=5).max()
* detect(when(signal > 60, '5m')).publish('Processing old messages 5m')
* detect(when(signal > 60, '30m')).publish('Processing old messages 30m')
* `,
* rules: [
* {
* description: "maximum > 60 for 5m",
* severity: "Warning",
* detectLabel: "Processing old messages 5m",
* notifications: ["Email,foo-alerts@bar.com"],
* },
* {
* description: "maximum > 60 for 30m",
* severity: "Critical",
* detectLabel: "Processing old messages 30m",
* notifications: ["Email,foo-alerts@bar.com"],
* },
* ],
* }));
* }
* ```
*
* ## Notification format
*
* As Splunk Observability Cloud supports different notification mechanisms, use a comma-delimited string to provide inputs. If you want to specify multiple notifications, each must be a member in the list, like so:
*
* See [Splunk Observability Cloud Docs](https://dev.splunk.com/observability/reference/api/detectors/latest) for more information.
*
* Here are some example of how to configure each notification type:
*
* ### Email
*
* ### Jira
*
* Note that the `credentialId` is the Splunk-provided ID shown after setting up your Jira integration. See also `signalfx.jira.Integration`.
*
* ### OpsGenie
*
* Note that the `credentialId` is the Splunk-provided ID shown after setting up your Opsgenie integration. `Team` here is hardcoded as the `responderType` as that is the only acceptable type as per the API docs.
*
* ### PagerDuty
*
* ### Slack
*
* Exclude the `#` on the channel name:
*
* ### Team
*
* Sends [notifications to a team](https://docs.signalfx.com/en/latest/managing/teams/team-notifications.html).
*
* ### TeamEmail
*
* Sends an email to every member of a team.
*
* ### Splunk On-Call (formerly VictorOps)
*
* ### Webhooks
*
* You need to include all the commas even if you only use a credential id.
*
* You can either configure a Webhook to use an existing integration's credential id:
*
* Or configure one inline:
*
* ## Import
*
* Detectors can be imported using their string ID (recoverable from URL: `/#/detector/v2/abc123/edit`, e.g.
*
* ```sh
* $ pulumi import signalfx:index/detector:Detector application_delay abc123
* ```
*/
class Detector extends pulumi.CustomResource {
/**
* Get an existing Detector 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 Detector(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* Returns true if the given object is an instance of Detector. 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'] === Detector.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["authorizedWriterTeams"] = state ? state.authorizedWriterTeams : undefined;
resourceInputs["authorizedWriterUsers"] = state ? state.authorizedWriterUsers : undefined;
resourceInputs["description"] = state ? state.description : undefined;
resourceInputs["detectorOrigin"] = state ? state.detectorOrigin : undefined;
resourceInputs["disableSampling"] = state ? state.disableSampling : undefined;
resourceInputs["endTime"] = state ? state.endTime : undefined;
resourceInputs["labelResolutions"] = state ? state.labelResolutions : undefined;
resourceInputs["maxDelay"] = state ? state.maxDelay : undefined;
resourceInputs["minDelay"] = state ? state.minDelay : undefined;
resourceInputs["name"] = state ? state.name : undefined;
resourceInputs["parentDetectorId"] = state ? state.parentDetectorId : undefined;
resourceInputs["programText"] = state ? state.programText : undefined;
resourceInputs["rules"] = state ? state.rules : undefined;
resourceInputs["showDataMarkers"] = state ? state.showDataMarkers : undefined;
resourceInputs["showEventLines"] = state ? state.showEventLines : undefined;
resourceInputs["startTime"] = state ? state.startTime : undefined;
resourceInputs["tags"] = state ? state.tags : undefined;
resourceInputs["teams"] = state ? state.teams : undefined;
resourceInputs["timeRange"] = state ? state.timeRange : undefined;
resourceInputs["timezone"] = state ? state.timezone : undefined;
resourceInputs["url"] = state ? state.url : undefined;
resourceInputs["vizOptions"] = state ? state.vizOptions : undefined;
}
else {
const args = argsOrState;
if ((!args || args.programText === undefined) && !opts.urn) {
throw new Error("Missing required property 'programText'");
}
if ((!args || args.rules === undefined) && !opts.urn) {
throw new Error("Missing required property 'rules'");
}
resourceInputs["authorizedWriterTeams"] = args ? args.authorizedWriterTeams : undefined;
resourceInputs["authorizedWriterUsers"] = args ? args.authorizedWriterUsers : undefined;
resourceInputs["description"] = args ? args.description : undefined;
resourceInputs["detectorOrigin"] = args ? args.detectorOrigin : undefined;
resourceInputs["disableSampling"] = args ? args.disableSampling : undefined;
resourceInputs["endTime"] = args ? args.endTime : undefined;
resourceInputs["maxDelay"] = args ? args.maxDelay : undefined;
resourceInputs["minDelay"] = args ? args.minDelay : undefined;
resourceInputs["name"] = args ? args.name : undefined;
resourceInputs["parentDetectorId"] = args ? args.parentDetectorId : undefined;
resourceInputs["programText"] = args ? args.programText : undefined;
resourceInputs["rules"] = args ? args.rules : undefined;
resourceInputs["showDataMarkers"] = args ? args.showDataMarkers : undefined;
resourceInputs["showEventLines"] = args ? args.showEventLines : undefined;
resourceInputs["startTime"] = args ? args.startTime : undefined;
resourceInputs["tags"] = args ? args.tags : undefined;
resourceInputs["teams"] = args ? args.teams : undefined;
resourceInputs["timeRange"] = args ? args.timeRange : undefined;
resourceInputs["timezone"] = args ? args.timezone : undefined;
resourceInputs["vizOptions"] = args ? args.vizOptions : undefined;
resourceInputs["labelResolutions"] = undefined /*out*/;
resourceInputs["url"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(Detector.__pulumiType, name, resourceInputs, opts);
}
}
exports.Detector = Detector;
/** @internal */
Detector.__pulumiType = 'signalfx:index/detector:Detector';
//# sourceMappingURL=detector.js.map