UNPKG

@pulumiverse/grafana

Version:

A Pulumi package for creating and managing grafana.

256 lines 9.2 kB
"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.Job = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * A job defines the queries and model parameters for a machine learning task. * * See [the Grafana Cloud docs](https://grafana.com/docs/grafana-cloud/alerting-and-irm/machine-learning/dynamic-alerting/forecasting/config/) for more information * on available hyperparameters for use in the `hyperParams` field. * * ## Example Usage * * ### Basic Forecast * * This forecast uses a Prometheus datasource, where the source query is defined in the `expr` field of the `queryParams` attribute. * * Other datasources are supported, but the structure `queryParams` may differ. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as grafana from "@pulumiverse/grafana"; * * const foo = new grafana.oss.DataSource("foo", { * type: "prometheus", * name: "prometheus-ds-test", * uid: "prometheus-ds-test-uid", * url: "https://my-instance.com", * basicAuthEnabled: true, * basicAuthUsername: "username", * jsonDataEncoded: JSON.stringify({ * httpMethod: "POST", * prometheusType: "Mimir", * prometheusVersion: "2.4.0", * }), * secureJsonDataEncoded: JSON.stringify({ * basicAuthPassword: "password", * }), * }); * const testJob = new grafana.machinelearning.Job("test_job", { * name: "Test Job", * metric: "tf_test_job", * datasourceType: "prometheus", * datasourceUid: foo.uid, * queryParams: { * expr: "grafanacloud_grafana_instance_active_user_count", * }, * }); * ``` * * ### Tuned Forecast * * This forecast has tuned hyperparameters to improve the accuracy of the model. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as grafana from "@pulumiverse/grafana"; * * const foo = new grafana.oss.DataSource("foo", { * type: "prometheus", * name: "prometheus-ds-test", * uid: "prometheus-ds-test-uid", * url: "https://my-instance.com", * basicAuthEnabled: true, * basicAuthUsername: "username", * jsonDataEncoded: JSON.stringify({ * httpMethod: "POST", * prometheusType: "Mimir", * prometheusVersion: "2.4.0", * }), * secureJsonDataEncoded: JSON.stringify({ * basicAuthPassword: "password", * }), * }); * const testJob = new grafana.machinelearning.Job("test_job", { * name: "Test Job", * metric: "tf_test_job", * datasourceType: "prometheus", * datasourceUid: foo.uid, * queryParams: { * expr: "grafanacloud_grafana_instance_active_user_count", * }, * hyperParams: { * daily_seasonality: "15", * weekly_seasonality: "10", * }, * customLabels: { * example_label: "example_value", * }, * }); * ``` * * ### Rescaled Forecast * * This forecast has had the data transformed using a power transformation in order to avoid negative lower predictions. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as grafana from "@pulumiverse/grafana"; * * const foo = new grafana.oss.DataSource("foo", { * type: "prometheus", * name: "prometheus-ds-test", * uid: "prometheus-ds-test-uid", * url: "https://my-instance.com", * basicAuthEnabled: true, * basicAuthUsername: "username", * jsonDataEncoded: JSON.stringify({ * httpMethod: "POST", * prometheusType: "Mimir", * prometheusVersion: "2.4.0", * }), * secureJsonDataEncoded: JSON.stringify({ * basicAuthPassword: "password", * }), * }); * const testJob = new grafana.machinelearning.Job("test_job", { * name: "Test Job", * metric: "tf_test_job", * datasourceType: "prometheus", * datasourceUid: foo.uid, * queryParams: { * expr: "grafanacloud_grafana_instance_active_user_count", * }, * hyperParams: { * transformation_id: "power", * }, * }); * ``` * * ### Forecast with Holidays * * This forecast has holidays which will be taken into account when training the model. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as grafana from "@pulumiverse/grafana"; * * const foo = new grafana.oss.DataSource("foo", { * type: "prometheus", * name: "prometheus-ds-test", * uid: "prometheus-ds-test-uid", * url: "https://my-instance.com", * basicAuthEnabled: true, * basicAuthUsername: "username", * jsonDataEncoded: JSON.stringify({ * httpMethod: "POST", * prometheusType: "Mimir", * prometheusVersion: "2.4.0", * }), * secureJsonDataEncoded: JSON.stringify({ * basicAuthPassword: "password", * }), * }); * const testHoliday = new grafana.machinelearning.Holiday("test_holiday", { * name: "Test Holiday", * customPeriods: [{ * name: "First of January", * startTime: "2023-01-01T00:00:00Z", * endTime: "2023-01-02T00:00:00Z", * }], * }); * const testJob = new grafana.machinelearning.Job("test_job", { * name: "Test Job", * metric: "tf_test_job", * datasourceType: "prometheus", * datasourceUid: foo.uid, * queryParams: { * expr: "grafanacloud_grafana_instance_active_user_count", * }, * holidays: [testHoliday.id], * }); * ``` * * ## Import * * ```sh * terraform import grafana_machine_learning_job.name "{{ id }}" * ``` */ class Job extends pulumi.CustomResource { /** * Get an existing Job 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 Job(name, state, { ...opts, id: id }); } /** * Returns true if the given object is an instance of Job. 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'] === Job.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["customLabels"] = state?.customLabels; resourceInputs["datasourceType"] = state?.datasourceType; resourceInputs["datasourceUid"] = state?.datasourceUid; resourceInputs["description"] = state?.description; resourceInputs["holidays"] = state?.holidays; resourceInputs["hyperParams"] = state?.hyperParams; resourceInputs["interval"] = state?.interval; resourceInputs["metric"] = state?.metric; resourceInputs["name"] = state?.name; resourceInputs["queryParams"] = state?.queryParams; resourceInputs["trainingWindow"] = state?.trainingWindow; } else { const args = argsOrState; if (args?.datasourceType === undefined && !opts.urn) { throw new Error("Missing required property 'datasourceType'"); } if (args?.datasourceUid === undefined && !opts.urn) { throw new Error("Missing required property 'datasourceUid'"); } if (args?.metric === undefined && !opts.urn) { throw new Error("Missing required property 'metric'"); } if (args?.queryParams === undefined && !opts.urn) { throw new Error("Missing required property 'queryParams'"); } resourceInputs["customLabels"] = args?.customLabels; resourceInputs["datasourceType"] = args?.datasourceType; resourceInputs["datasourceUid"] = args?.datasourceUid; resourceInputs["description"] = args?.description; resourceInputs["holidays"] = args?.holidays; resourceInputs["hyperParams"] = args?.hyperParams; resourceInputs["interval"] = args?.interval; resourceInputs["metric"] = args?.metric; resourceInputs["name"] = args?.name; resourceInputs["queryParams"] = args?.queryParams; resourceInputs["trainingWindow"] = args?.trainingWindow; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(Job.__pulumiType, name, resourceInputs, opts); } } exports.Job = Job; /** @internal */ Job.__pulumiType = 'grafana:machineLearning/job:Job'; //# sourceMappingURL=job.js.map