Skip to content
This repository has been archived by the owner on Jan 8, 2022. It is now read-only.

Fix various things #9

Merged
merged 4 commits into from
Jun 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/resources/dashboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ The following arguments are supported in the resource block:
* `label` - (Optional) Text shown in the dropdown when selecting this overlay from the menu.
* `color` - (Optional) Color to use : gray, blue, azure, navy, brown, orange, yellow, iris, magenta, pink, purple, violet, lilac, emerald, green, aquamarine. ![Colors](https://github.com/Yelp/terraform-provider-signalform/raw/master/docs/resources/colors.png)
* `signal` - Search term used to choose the events shown in the overlay.
* `type` - (Optional) Can be set to `eventTimeSeries` (the default) to refer to externally reported events, or `detectorEvents` to refer to events from detector triggers.
* `source` - (Optional) Each element specifies a filter to use against the signal specified in the `signal`.
* `property` - The name of a dimension to filter against.
* `values` - A list of values to be used with the `property`, they will be combined via `OR`.
Expand Down
2 changes: 2 additions & 0 deletions docs/resources/detector.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ variable "clusters" {
* `description` - (Optional) Description of the detector.
* `max_delay` - (Optional) How long (in seconds) to wait for late datapoints. See <https://signalfx-product-docs.readthedocs-hosted.com/en/latest/charts/chart-builder.html#delayed-datapoints> for more info. Max value is `900` seconds (15 minutes).
* `show_data_markers` - (Optional) When `true`, markers will be drawn for each datapoint within the visualization. `false` by default.
* `show_event_lines` - (Optional) When `true`, the visualization will display a vertical line for each event trigger. `false` by default.
* `disable_sampling` - (Optional) When `false`, the visualization may sample the output timeseries rather than displaying them all. `false` by default.
* `time_range` - (Optional) From when to display data. SignalFx time syntax (e.g. `"-5m"`, `"-1h"`). Conflicts with `start_time` and `end_time`.
* `start_time` - (Optional) Seconds since epoch. Used for visualization. Conflicts with `time_range`.
* `end_time` - (Optional) Seconds since epoch. Used for visualization. Conflicts with `time_range`.
Expand Down
28 changes: 27 additions & 1 deletion src/terraform-provider-signalform/signalform/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,13 @@ func dashboardResource() *schema.Resource {
Required: true,
Description: "Search term used to define events",
},
"type": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Default: "eventTimeSeries",
Description: "Source for this event's data. Can be \"eventTimeSeries\" (default) or \"detectorEvents\".",
ValidateFunc: validateEventOverlayType,
},
"source": &schema.Schema{
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -352,6 +359,13 @@ func dashboardResource() *schema.Resource {
Required: true,
Description: "Search term used to define events",
},
"type": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Default: "eventTimeSeries",
Description: "Source for this event's data. Can be \"eventTimeSeries\" (default) or \"detectorEvents\".",
ValidateFunc: validateEventOverlayType,
},
"source": &schema.Schema{
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -573,7 +587,7 @@ func getDashboardEventOverlays(overlays []interface{}) []map[string]interface{}
item := make(map[string]interface{})
item["eventSignal"] = map[string]interface{}{
"eventSearchText": overlay["signal"].(string),
"eventType": "eventTimeSeries",
"eventType": overlay["type"].(string),
}
if val, ok := overlay["line"].(bool); ok {
item["eventLine"] = val
Expand Down Expand Up @@ -671,3 +685,15 @@ func validateChartsResolution(v interface{}, k string) (we []string, errors []er
errors = append(errors, fmt.Errorf("%s not allowed; must be one of: %s", value, strings.Join(allowedWords, ", ")))
return
}

func validateEventOverlayType(v interface{}, k string) (we []string, errors []error) {
value := v.(string)
allowedWords := []string{"eventTimeSeries", "detectorEvents"}
for _, word := range allowedWords {
if value == word {
return
}
}
errors = append(errors, fmt.Errorf("%s not allowed; must be one of: %s", value, strings.Join(allowedWords, ", ")))
return
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,7 @@ func getPayloadDashboardGroup(d *schema.ResourceData) ([]byte, error) {
}

if val, ok := d.GetOk("teams"); ok {
teams := []string{}
for _, team := range val.([]interface{}) {
teams = append(teams, team.(string))
}
payload["teams"] = teams
payload["teams"] = val.([]interface{})
}

return json.Marshal(payload)
Expand Down
30 changes: 20 additions & 10 deletions src/terraform-provider-signalform/signalform/detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@ func detectorResource() *schema.Resource {
Default: false,
Description: "(false by default) When true, markers will be drawn for each datapoint within the visualization.",
},
"show_event_lines": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "(false by default) When true, vertical lines will be drawn for each triggered event within the visualization.",
},
"disable_sampling": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "(false by default) When false, samples a subset of the output MTS in the visualization.",
},
"time_range": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -223,19 +235,11 @@ func getPayloadDetector(d *schema.ResourceData) ([]byte, error) {
}

if val, ok := d.GetOk("teams"); ok {
teams := []string{}
for _, team := range val.([]interface{}) {
teams = append(teams, team.(string))
}
payload["teams"] = teams
payload["teams"] = val.([]interface{})
}

if val, ok := d.GetOk("tags"); ok {
tags := []string{}
for _, tag := range val.([]interface{}) {
tags = append(tags, tag.(string))
}
payload["tags"] = tags
payload["tags"] = val.([]interface{})
}

return json.Marshal(payload)
Expand All @@ -246,6 +250,12 @@ func getVisualizationOptionsDetector(d *schema.ResourceData) map[string]interfac
if val, ok := d.GetOk("show_data_markers"); ok {
viz["showDataMarkers"] = val.(bool)
}
if val, ok := d.GetOk("show_event_lines"); ok {
viz["showEventLines"] = val.(bool)
}
if val, ok := d.GetOk("disable_sampling"); ok {
viz["disableSampling"] = val.(bool)
}

timeMap := make(map[string]interface{})
if val, ok := d.GetOk("time_range"); ok {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func getSingleValueChartOptions(d *schema.ResourceData) map[string]interface{} {
if val == "Scale" {
if colorScaleOptions := getColorScaleOptions(d); len(colorScaleOptions) > 0 {
viz["colorBy"] = "Scale"
viz["colorScale"] = colorScaleOptions
viz["colorScale2"] = colorScaleOptions
}
} else {
viz["colorBy"] = val.(string)
Expand Down