UNPKG

@pulumiverse/grafana

Version:

A Pulumi package for creating and managing grafana.

362 lines (361 loc) 13 kB
import * as pulumi from "@pulumi/pulumi"; /** * 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 }}" * ``` */ export declare 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: string, id: pulumi.Input<pulumi.ID>, state?: JobState, opts?: pulumi.CustomResourceOptions): Job; /** * 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: any): obj is Job; /** * An object representing the custom labels added on the forecast. */ readonly customLabels: pulumi.Output<{ [key: string]: string; } | undefined>; /** * The type of datasource being queried. Currently allowed values are prometheus, grafana-prometheus-datasource, grafana-amazonprometheus-datasource, loki, grafana-loki-datasource, graphite, grafana-graphite-datasource, grafana-datadog-datasource, postgres, grafana-postgresql-datasource, doitintl-bigquery-datasource, grafana-bigquery-datasource, grafana-snowflake-datasource, influxdb, grafana-influxdb-datasource, grafana-splunk-datasource, elasticsearch, grafana-elasticsearch-datasource, and grafana-mongodb-datasource. */ readonly datasourceType: pulumi.Output<string>; /** * The uid of the datasource to query. */ readonly datasourceUid: pulumi.Output<string>; /** * A description of the job. */ readonly description: pulumi.Output<string | undefined>; /** * A list of holiday IDs or names to take into account when training the model. */ readonly holidays: pulumi.Output<string[] | undefined>; /** * The hyperparameters used to fine tune the algorithm. See https://grafana.com/docs/grafana-cloud/alerting-and-irm/machine-learning/forecasts/models/ for the full list of available hyperparameters. */ readonly hyperParams: pulumi.Output<{ [key: string]: string; } | undefined>; /** * The data interval in seconds to train the data on. */ readonly interval: pulumi.Output<number | undefined>; /** * The metric used to query the job results. */ readonly metric: pulumi.Output<string>; /** * The name of the job. */ readonly name: pulumi.Output<string>; /** * An object representing the query params to query Grafana with. */ readonly queryParams: pulumi.Output<{ [key: string]: string; }>; /** * The data interval in seconds to train the data on. */ readonly trainingWindow: pulumi.Output<number | undefined>; /** * Create a Job resource with the given unique name, arguments, and options. * * @param name The _unique_ name of the resource. * @param args The arguments to use to populate this resource's properties. * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args: JobArgs, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering Job resources. */ export interface JobState { /** * An object representing the custom labels added on the forecast. */ customLabels?: pulumi.Input<{ [key: string]: pulumi.Input<string>; }>; /** * The type of datasource being queried. Currently allowed values are prometheus, grafana-prometheus-datasource, grafana-amazonprometheus-datasource, loki, grafana-loki-datasource, graphite, grafana-graphite-datasource, grafana-datadog-datasource, postgres, grafana-postgresql-datasource, doitintl-bigquery-datasource, grafana-bigquery-datasource, grafana-snowflake-datasource, influxdb, grafana-influxdb-datasource, grafana-splunk-datasource, elasticsearch, grafana-elasticsearch-datasource, and grafana-mongodb-datasource. */ datasourceType?: pulumi.Input<string>; /** * The uid of the datasource to query. */ datasourceUid?: pulumi.Input<string>; /** * A description of the job. */ description?: pulumi.Input<string>; /** * A list of holiday IDs or names to take into account when training the model. */ holidays?: pulumi.Input<pulumi.Input<string>[]>; /** * The hyperparameters used to fine tune the algorithm. See https://grafana.com/docs/grafana-cloud/alerting-and-irm/machine-learning/forecasts/models/ for the full list of available hyperparameters. */ hyperParams?: pulumi.Input<{ [key: string]: pulumi.Input<string>; }>; /** * The data interval in seconds to train the data on. */ interval?: pulumi.Input<number>; /** * The metric used to query the job results. */ metric?: pulumi.Input<string>; /** * The name of the job. */ name?: pulumi.Input<string>; /** * An object representing the query params to query Grafana with. */ queryParams?: pulumi.Input<{ [key: string]: pulumi.Input<string>; }>; /** * The data interval in seconds to train the data on. */ trainingWindow?: pulumi.Input<number>; } /** * The set of arguments for constructing a Job resource. */ export interface JobArgs { /** * An object representing the custom labels added on the forecast. */ customLabels?: pulumi.Input<{ [key: string]: pulumi.Input<string>; }>; /** * The type of datasource being queried. Currently allowed values are prometheus, grafana-prometheus-datasource, grafana-amazonprometheus-datasource, loki, grafana-loki-datasource, graphite, grafana-graphite-datasource, grafana-datadog-datasource, postgres, grafana-postgresql-datasource, doitintl-bigquery-datasource, grafana-bigquery-datasource, grafana-snowflake-datasource, influxdb, grafana-influxdb-datasource, grafana-splunk-datasource, elasticsearch, grafana-elasticsearch-datasource, and grafana-mongodb-datasource. */ datasourceType: pulumi.Input<string>; /** * The uid of the datasource to query. */ datasourceUid: pulumi.Input<string>; /** * A description of the job. */ description?: pulumi.Input<string>; /** * A list of holiday IDs or names to take into account when training the model. */ holidays?: pulumi.Input<pulumi.Input<string>[]>; /** * The hyperparameters used to fine tune the algorithm. See https://grafana.com/docs/grafana-cloud/alerting-and-irm/machine-learning/forecasts/models/ for the full list of available hyperparameters. */ hyperParams?: pulumi.Input<{ [key: string]: pulumi.Input<string>; }>; /** * The data interval in seconds to train the data on. */ interval?: pulumi.Input<number>; /** * The metric used to query the job results. */ metric: pulumi.Input<string>; /** * The name of the job. */ name?: pulumi.Input<string>; /** * An object representing the query params to query Grafana with. */ queryParams: pulumi.Input<{ [key: string]: pulumi.Input<string>; }>; /** * The data interval in seconds to train the data on. */ trainingWindow?: pulumi.Input<number>; }