oci_log_analytics_namespace_scheduled_task
This resource provides the Namespace Scheduled Task resource in Oracle Cloud Infrastructure Log Analytics service. Api doc link for the resource: https://docs.oracle.com/iaas/api/#/en/logan-api-spec/latest/NamespaceScheduledTask
Example terraform configs related to the resource : https://github.com/oracle/terraform-provider-oci/tree/master/examples/log_analytics
Schedule a task as specified and return task info.
Example Usage
resource "oci_log_analytics_namespace_scheduled_task" "test_namespace_scheduled_task" {
#Required
compartment_id = var.compartment_id
kind = var.namespace_scheduled_task_kind
namespace = var.namespace_scheduled_task_namespace
#Optional
action {
#Required
type = var.namespace_scheduled_task_action_type
#Optional
compartment_id_in_subtree = var.namespace_scheduled_task_action_compartment_id_in_subtree
data_type = var.namespace_scheduled_task_action_data_type
metric_extraction {
#Optional
compartment_id = var.compartment_id
#Optional
metric_collections {
#1 Required
dimensions {
#Optional
dimension_name = var.namespace_scheduled_task_action_metric_extraction_metric_collections_dimensions_dimension_name
query_field_name = var.namespace_scheduled_task_action_metric_extraction_metric_collections_dimensions_query_field_name
}
metric_name = oci_monitoring_metric.test_metric.name
metric_query_field_name = var.namespace_scheduled_task_action_metric_extraction_metric_collections_metric_query_field_name
query_table_name = oci_nosql_table.test_table.name
}
#Optional
metric_name = oci_monitoring_metric.test_metric.name
namespace = var.namespace_scheduled_task_action_metric_extraction_namespace
resource_group = var.namespace_scheduled_task_action_metric_extraction_resource_group
}
purge_compartment_id = oci_identity_compartment.test_compartment.id
purge_duration = var.namespace_scheduled_task_action_purge_duration
query_string = var.namespace_scheduled_task_action_query_string
saved_search_id = oci_log_analytics_saved_search.test_saved_search.id
template_details {
#Optional
template_id = oci_log_analytics_template.test_template.id
template_params {
#Optional
key_field = var.namespace_scheduled_task_action_template_details_template_params_key_field
value_field = var.namespace_scheduled_task_action_template_details_template_params_value_field
}
}
}
defined_tags = {"foo-namespace.bar-key"= "value"}
description = var.namespace_scheduled_task_description
display_name = var.namespace_scheduled_task_display_name
freeform_tags = {"bar-key"= "value"}
saved_search_id = oci_log_analytics_saved_search.test_saved_search.id
schedules {
#Required
type = var.namespace_scheduled_task_schedules_type
#Optional
expression = var.namespace_scheduled_task_schedules_expression
misfire_policy = var.namespace_scheduled_task_schedules_misfire_policy
query_offset_secs = var.namespace_scheduled_task_schedules_query_offset_secs
recurring_interval = var.namespace_scheduled_task_schedules_recurring_interval
repeat_count = var.namespace_scheduled_task_schedules_repeat_count
time_end = var.namespace_scheduled_task_schedules_time_end
time_zone = var.namespace_scheduled_task_schedules_time_zone
}
task_type = var.namespace_scheduled_task_task_type
}
Argument Reference
The following arguments are supported:
action- (Required when kind=STANDARD) Action for scheduled task.compartment_id_in_subtree- (Applicable when type=PURGE) if true, purge child compartments datadata_type- (Required when type=PURGE) the type of the log data to be purgedmetric_extraction- (Applicable when type=STREAM) Specify metric extraction for SAVED_SEARCH scheduled task execution to post to Oracle Cloud Infrastructure Monitoring.compartment_id- (Required when type=STREAM) (Updatable) The compartment OCID (https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the extracted metric.metric_name- (Required when type=STREAM and no metriccollections) The metric name of the extracted metric. A valid value starts with an alphabetical character and includes only alphanumeric characters, periods (.), underscores (), hyphens (-), and dollar signs ($).namespace- (Required when type=STREAM) The namespace of the extracted metric. A valid value starts with an alphabetical character and includes only alphanumeric characters and underscores (_).resource_group- (Applicable when type=STREAM) The resource group of the extracted metric. A valid value starts with an alphabetical character and includes only alphanumeric characters, periods (.), underscores (_), hyphens (-), and dollar signs ($).metric_collections- (Required when type=STREAM and no metric_name supplied) Details for the metrics to be collected.dimensions- (Minumum 1 Required when type=STREAM and metric_collections is provided) Selected dimension fields for the metric collection.dimension_name- (Applicable when type=STREAM) Dimension name to be stored with the metric.query_field_name- (Required when type=STREAM) Output field in the query to be used as the source for the metric dimension.metric_name- (Required when type=STREAM) The metric name for this metric collection. A valid value starts with an alphabetical character and includes only alphanumeric characters, periods (.), underscores (_), hyphens (-), and dollar signs ($).metric_query_field_name- (Required when type=STREAM) Output field in the query to be used as the metric value.query_table_name- (Applicable when type=STREAM) Output table in the query.
purge_compartment_id- (Required when type=PURGE) the compartment OCID under which the data will be purgedpurge_duration- (Required when type=PURGE) The duration of data to be retained, which is used to calculate the timeDataEnded when the task fires. The value should be negative. Purge duration in ISO 8601 extended format as described in https://en.wikipedia.org/wiki/ISO_8601#Durations. The largest supported unit is D, e.g. -P365D (not -P1Y) or -P14D (not -P2W).query_string- (Required when type=PURGE) Purge query string.saved_search_id- (Applicable when type=STREAM) The ManagementSavedSearch id [OCID] utilized in the action. Should not be provided when a template ID is present.template_details- (Applicable when type=STREAM) details for scheduled task using templatetemplate_id- (Applicable when type=STREAM) The template Id of a particular template. Should not be provided when a saved search ID is present.template_params- (Applicable when type=STREAM) To store macro params.key_field- (Applicable when type=STREAM) Contains a template parameter’s name.value_field- (Applicable when type=STREAM) Contains the desired value for a given parameter.
type- (Required) Action type discriminator.
compartment_id- (Required) (Updatable) Compartment Identifier OCID.defined_tags- (Optional) (Updatable) Defined tags for this resource. Each key is predefined and scoped to a namespace. Example:{"foo-namespace.bar-key": "value"}description- (Optional) (Updatable) Description for this resource.display_name- (Optional) (Updatable) A user-friendly name that is changeable and that does not have to be unique. Format: a leading alphanumeric, followed by zero or more alphanumerics, underscores, spaces, backslashes, or hyphens in any order). No trailing spaces allowed.freeform_tags- (Optional) (Updatable) Simple key-value pair that is applied without any predefined name, type or scope. Exists for cross-compatibility only. Example:{"bar-key": "value"}kind- (Required) (Updatable) Discriminator.namespace- (Required) The Log Analytics namespace used for the request. The namespace can be obtained by running ‘oci os ns get’saved_search_id- (Required when kind=ACCELERATION) The ManagementSavedSearch id [OCID] to be accelerated.schedules- (Applicable when kind=STANDARD) (Updatable) Schedules, typically a single schedule. Note there may only be a single schedule for SAVED_SEARCH and PURGE scheduled tasks.expression- (Applicable when type=CRON) (Updatable) Value in cron format.misfire_policy- (Applicable when kind=STANDARD) (Updatable) Schedule misfire retry policy.query_offset_secs- (Applicable when kind=STANDARD) (Updatable) Number of seconds to offset the query time window by to accommodate capture late arriving data. For example, a schedule run at 12:00 with a 10 minute interval and queryOffsetSecs=120 will use the query time window of 11:48-11:58 rather than 11:50-12:00 without queryOffsetSecs.recurring_interval- (Applicable when type=FIXED_FREQUENCY) (Updatable) Recurring interval in ISO 8601 extended format as described in https://en.wikipedia.org/wiki/ISO_8601#Durations. The largest supported unit is D, e.g. P14D (not P2W). The value must be at least 5 minutes (PT5M) and at most 3 weeks (P21D or PT30240M).repeat_count- (Applicable when type=FIXED_FREQUENCY) (Updatable) Number of times (0-based) to execute until auto-stop. Default value -1 will execute indefinitely. Value 0 will execute once.time_end- (Applicable when kind=STANDARD) (Updatable) End time for the schedule, even if the schedule would otherwise have remaining executions.time_zone- (Applicable when type=CRON) (Updatable) Time zone, by default UTC.type- (Required) (Updatable) Schedule type discriminator.
task_type- (Required when kind=STANDARD) Task type.
** IMPORTANT ** Any change to a property that does not support update will force the destruction and recreation of the resource with the new property values
Attributes Reference
The following attributes are exported:
action- Action for scheduled task.compartment_id_in_subtree- if true, purge child compartments datadata_type- the type of the log data to be purgedmetric_extraction- Specify metric extraction for SAVED_SEARCH scheduled task execution to post to Oracle Cloud Infrastructure Monitoring.compartment_id- The compartment OCID (https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the extracted metric.metric_collections- Details for the metrics to be collected.dimensions- Selected dimension fields for the metric collection.dimension_name- Dimension name to be stored with the metric.query_field_name- Output field in the query to be used as the source for the metric dimension.
metric_name- The metric name for this metric collection. A valid value starts with an alphabetical character and includes only alphanumeric characters, periods (.), underscores (_), hyphens (-), and dollar signs ($).metric_query_field_name- Output field in the query to be used as the metric value.query_table_name- Output table in the query.
metric_name- The metric name of the extracted metric. A valid value starts with an alphabetical character and includes only alphanumeric characters, periods (.), underscores (_), hyphens (-), and dollar signs ($).namespace- The namespace of the extracted metric. A valid value starts with an alphabetical character and includes only alphanumeric characters and underscores (_).resource_group- The resource group of the extracted metric. A valid value starts with an alphabetical character and includes only alphanumeric characters, periods (.), underscores (_), hyphens (-), and dollar signs ($).
purge_compartment_id- the compartment OCID under which the data will be purgedpurge_duration- The duration of data to be retained, which is used to calculate the timeDataEnded when the task fires. The value should be negative. Purge duration in ISO 8601 extended format as described in https://en.wikipedia.org/wiki/ISO_8601#Durations. The largest supported unit is D, e.g. -P365D (not -P1Y) or -P14D (not -P2W).query_string- Purge query string.saved_search_id- The ManagementSavedSearch id [OCID] utilized in the action.template_details- details for scheduled task using templatetemplate_id- The template Id of a particular template.template_params- To store macro params.key_field- Contains the name of a template parameter.value_field- Contains the desired value for the parameter.
type- Action type discriminator.
compartment_id- Compartment Identifier OCID.defined_tags- Defined tags for this resource. Each key is predefined and scoped to a namespace. Example:{"foo-namespace.bar-key": "value"}description- Description for this resource.display_name- A user-friendly name that is changeable and that does not have to be unique. Format: a leading alphanumeric, followed by zero or more alphanumerics, underscores, spaces, backslashes, or hyphens in any order). No trailing spaces allowed.freeform_tags- Simple key-value pair that is applied without any predefined name, type or scope. Exists for cross-compatibility only. Example:{"bar-key": "value"}id- The OCID of the data plane resource.kind- Discriminator.num_occurrences- Number of execution occurrences.schedules- Schedules.expression- Value in cron format.misfire_policy- Schedule misfire retry policy.query_offset_secs- Number of seconds to offset the query time window by to accommodate capture late arriving data. For example, a schedule run at 12:00 with a 10 minute interval and queryOffsetSecs=120 will use the query time window of 11:48-11:58 rather than 11:50-12:00 without queryOffsetSecs.recurring_interval- Recurring interval in ISO 8601 extended format as described in https://en.wikipedia.org/wiki/ISO_8601#Durations. The largest supported unit is D, e.g. P14D (not P2W). The value must be at least 5 minutes (PT5M) and at most 3 weeks (P21D or PT30240M).repeat_count- Number of times (0-based) to execute until auto-stop. Default value -1 will execute indefinitely. Value 0 will execute once.time_end- End time for the schedule, even if the schedule would otherwise have remaining executions.time_zone- Time zone, by default UTC.type- Schedule type discriminator.
state- The current state of the scheduled task.task_status- Status of the scheduled task. - PURGE_RESOURCE_NOT_FOUND - LIMIT_EXCEEDEDtask_type- Task type.time_created- The date and time the scheduled task was created, in the format defined by RFC3339.time_updated- The date and time the scheduled task was last updated, in the format defined by RFC3339.work_request_id- most recent Work Request Identifier OCID for the asynchronous request.
Schedules
There are parameters which require a specific constant value to be supplied.
misfire_policy
‘RETRY_INDEFINITELY’
A constant which can be used with the misfire_policy property of a Schedule. This constant has a value of “RETRY_INDEFINITELY”
‘RETRY_ONCE’
A constant which can be used with the misfire_policy property of a Schedule. This constant has a value of “RETRY_ONCE”
‘SKIP’
A constant which can be used with the misfire_policy property of a Schedule. This constant has a value of “SKIP”
type
‘AUTO’
A constant which can be used with the type property of a Schedule. This constant has a value of “AUTO”
‘CRON’
A constant which can be used with the type property of a Schedule. This constant has a value of “CRON”
‘FIXED_FREQUENCY’
A constant which can be used with the type property of a Schedule. This constant has a value of “FIXED_FREQUENCY”
Timeouts
The timeouts block allows you to specify timeouts for certain operations:
* create - (Defaults to 20 minutes), when creating the Namespace Scheduled Task
* update - (Defaults to 20 minutes), when updating the Namespace Scheduled Task
* delete - (Defaults to 20 minutes), when destroying the Namespace Scheduled Task
Import
NamespaceScheduledTasks can be imported using the id, e.g.
$ terraform import oci_log_analytics_namespace_scheduled_task.test_namespace_scheduled_task "namespaces/{namespaceName}/scheduledTasks/{scheduledTaskId}"