|
| 1 | +--- |
| 2 | +layout: "sumologic" |
| 3 | +page_title: "SumoLogic: sumologic_metrics_search_v2" |
| 4 | +description: |- |
| 5 | + Provides a Sumologic Metrics Search V2 |
| 6 | +--- |
| 7 | + |
| 8 | +# sumologic_metrics_search_v2 |
| 9 | +Provides a [Sumologic Metrics Search V2][1]. |
| 10 | + |
| 11 | +## Example Usage |
| 12 | +```hcl |
| 13 | +data "sumologic_personal_folder" "personalFolder" {} |
| 14 | +
|
| 15 | +resource "sumologic_metrics_search_v2" "example_metrics_search" { |
| 16 | + title = "Demo Metrics Search" |
| 17 | + description = "Demo search description" |
| 18 | + folder_id = data.sumologic_personal_folder.personalFolder.id |
| 19 | + queries { |
| 20 | + query_key = "A" |
| 21 | + query_string = "metric=cpu_idle | avg" |
| 22 | + query_type = "Metrics" |
| 23 | + metrics_query_mode = "Advanced" |
| 24 | + } |
| 25 | + time_range { |
| 26 | + begin_bounded_time_range { |
| 27 | + from { |
| 28 | + relative_time_range { |
| 29 | + relative_time = "-30m" |
| 30 | + } |
| 31 | + } |
| 32 | + } |
| 33 | + } |
| 34 | +} |
| 35 | +``` |
| 36 | + |
| 37 | +## Argument reference |
| 38 | + |
| 39 | +The following arguments are supported: |
| 40 | + |
| 41 | +- `title` - (Required) Title of the search. |
| 42 | +- `description` - (Required) Description of the search. |
| 43 | +- `folder_id` - (Required) The identifier of the folder to create the metrics search in. |
| 44 | +- `queries` - (Required) Array of objects [MetricsSearchQueryV2](#schema-for-metrics_search_query). Metrics queries, up to the maximum of six. |
| 45 | +- `time_range` - (Block List, Max: 1, Required) Time range of the log search. See [time range schema](#schema-for-time_range) |
| 46 | + |
| 47 | +### Schema for `queries` |
| 48 | +- `query_key` - (Required) Key for the query row, A to Z letter. |
| 49 | +- `query_string` - (Required) A metric query consists of a metric, one or more filters and optionally, one or more [Metrics Operators](https://help.sumologic.com/?cid=10144). |
| 50 | +- `query_type` - (Required) The type of the query, either `Metrics` or `Logs`. |
| 51 | +- `metrics_query_mode` - (Optional) Will ONLY be specified for metrics queries. The provider only supports `Advanced` as metrics query mode. |
| 52 | + |
| 53 | +### Schema for `time_range` |
| 54 | +- `complete_literal_time_range` - (Block List, Max: 1, Optional) Literal time range. See |
| 55 | +[complete_literal_time_range schema](#schema-for-complete_literal_time_range) for details. |
| 56 | +- `begin_bounded_time_range` - (Block List, Max: 1, Optional) Bounded time range. See |
| 57 | +[begin_bounded_time_range schema](#schema-for-begin_bounded_time_range) schema for details. |
| 58 | + |
| 59 | +### Schema for `complete_literal_time_range` |
| 60 | +- `range_name` - (Required) Name of complete literal time range. One of `today`, `yesterday`, `previous_week`, and |
| 61 | + `previous_month`. |
| 62 | + |
| 63 | +### Schema for `begin_bounded_time_range` |
| 64 | +- `from` - (Block List, Max: 1, Required) Start boundary of bounded time range. See |
| 65 | +[time_range_boundary schema](#schema-for-time_range_boundary) for details. |
| 66 | +- `to` - (Block List, Max: 1, Optional) End boundary of bounded time range. See |
| 67 | +[time_range_boundary schema](#schema-for-time_range_boundary) for details. |
| 68 | + |
| 69 | +### Schema for `time_range_boundary` |
| 70 | +- `epoch_time_range` - (Block List, Optional) Time since the epoch. |
| 71 | + - `epoch_millis` - (Required) Time as a number of milliseconds since the epoch. |
| 72 | + |
| 73 | +- `iso8601_time_range` - (Block List, Optional) Time in ISO 8601 format. |
| 74 | + - `iso8601_time` - (Required) Time as a string in ISO 8601 format. |
| 75 | + |
| 76 | +- `relative_time_range` - (Block List, Optional) Time in relative format. |
| 77 | + - `relative_time` - (Required) Relative time as a string consisting of following elements: |
| 78 | + 1. `-` (optional): minus sign indicates time in the past, |
| 79 | + 2. `<number>`: number of time units, |
| 80 | + 3. `<time_unit>`: time unit; possible values are: `w` (week), `d` (day), `h` (hour), `m` (minute), `s` (second). |
| 81 | + |
| 82 | + Multiple pairs of `<number><time_unit>` may be provided, and they may be in any order. For example, |
| 83 | + `-2w5d3h` points to the moment in time 2 weeks, 5 days and 3 hours ago. |
| 84 | + |
| 85 | +- `literal_time_range` - (Block List, Optional) Time in literal format. |
| 86 | + - `range_name` - (Required) One of `now`, `second`, `minute`, `hour`, `day`, `today`, `week`, `month`, `year`. |
| 87 | + |
| 88 | +## Attributes reference |
| 89 | +In addition to all arguments above, the following attributes are exported: |
| 90 | + |
| 91 | +- `id` - The ID of the metrics search. |
| 92 | + |
| 93 | + |
| 94 | +## Import |
| 95 | +A metrics search can be imported using it's identifier, e.g.: |
| 96 | +```hcl |
| 97 | +terraform import sumologic_metrics_search_v2.example_search 0000000007FFD79D |
| 98 | +``` |
| 99 | + |
| 100 | +[1]: https://help.sumologic.com/docs/metrics/metrics-queries/metrics-explorer/ |
0 commit comments