Skip to content

Commit

Permalink
feat(monitoring): add new relic monitoring daemon config (#1442)
Browse files Browse the repository at this point in the history
* feat(canary): add new relic monitoring daemon config

* feat(monitoring): replace short description for metric store commands

s/authentication method/metric store
  • Loading branch information
jwelch92 authored and ezimanyi committed Oct 10, 2019
1 parent e1bd180 commit b4de6f0
Show file tree
Hide file tree
Showing 9 changed files with 261 additions and 9 deletions.
86 changes: 80 additions & 6 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,10 @@
* [**hal config metric-stores datadog edit**](#hal-config-metric-stores-datadog-edit)
* [**hal config metric-stores datadog enable**](#hal-config-metric-stores-datadog-enable)
* [**hal config metric-stores edit**](#hal-config-metric-stores-edit)
* [**hal config metric-stores newrelic**](#hal-config-metric-stores-newrelic)
* [**hal config metric-stores newrelic disable**](#hal-config-metric-stores-newrelic-disable)
* [**hal config metric-stores newrelic edit**](#hal-config-metric-stores-newrelic-edit)
* [**hal config metric-stores newrelic enable**](#hal-config-metric-stores-newrelic-enable)
* [**hal config metric-stores prometheus**](#hal-config-metric-stores-prometheus)
* [**hal config metric-stores prometheus disable**](#hal-config-metric-stores-prometheus-disable)
* [**hal config metric-stores prometheus edit**](#hal-config-metric-stores-prometheus-edit)
Expand Down Expand Up @@ -6004,6 +6008,7 @@ hal config metric-stores [parameters] [subcommands]
#### Subcommands
* `datadog`: Configure your datadog metric store.
* `edit`: Configure global metric stores properties.
* `newrelic`: Configure your newrelic metric store.
* `prometheus`: Configure your prometheus metric store.
* `stackdriver`: Configure your stackdriver metric store.

Expand All @@ -6023,7 +6028,7 @@ hal config metric-stores datadog [parameters] [subcommands]

#### Subcommands
* `disable`: Set the datadog method as disabled
* `edit`: Edit the datadog authentication method.
* `edit`: Edit the datadog metric store.
* `enable`: Set the datadog method as enabled

---
Expand All @@ -6044,7 +6049,7 @@ hal config metric-stores datadog disable [parameters]
---
## hal config metric-stores datadog edit

Edit the datadog authentication method.
Edit the datadog metric store.

#### Usage
```
Expand Down Expand Up @@ -6092,6 +6097,75 @@ hal config metric-stores edit [parameters]
* `--period`: (*Required*) Set the polling period for the monitoring daemon.


---
## hal config metric-stores newrelic

Configure your newrelic metric store.

#### Usage
```
hal config metric-stores newrelic [parameters] [subcommands]
```

#### Parameters
* `--deployment`: If supplied, use this Halyard deployment. This will _not_ create a new deployment.
* `--no-validate`: (*Default*: `false`) Skip validation.

#### Subcommands
* `disable`: Set the newrelic method as disabled
* `edit`: Edit the newrelic metric store.
* `enable`: Set the newrelic method as enabled

---
## hal config metric-stores newrelic disable

Set the newrelic method as disabled

#### Usage
```
hal config metric-stores newrelic disable [parameters]
```

#### Parameters
* `--deployment`: If supplied, use this Halyard deployment. This will _not_ create a new deployment.
* `--no-validate`: (*Default*: `false`) Skip validation.


---
## hal config metric-stores newrelic edit

Edit the newrelic metric store.

#### Usage
```
hal config metric-stores newrelic edit [parameters]
```

#### Parameters
* `--add-tag`: Add this tag to the list of tags. Use the format key:value i.e. --add-tag app:test
* `--deployment`: If supplied, use this Halyard deployment. This will _not_ create a new deployment.
* `--host`: The URL to post metric data to. In almost all cases, this is set correctly by default and should not be used.
* `--insert-key`: Your New Relic Insights insert key
* `--no-validate`: (*Default*: `false`) Skip validation.
* `--remove-tag`: Remove this tag from the list of tags. Use the name of the tag you want to remove i.e. --remove-tag app
* `--tags`: (*Default*: `[]`) Your custom tags. Please delimit the KVP with colons i.e. --tags app:test env:dev


---
## hal config metric-stores newrelic enable

Set the newrelic method as enabled

#### Usage
```
hal config metric-stores newrelic enable [parameters]
```

#### Parameters
* `--deployment`: If supplied, use this Halyard deployment. This will _not_ create a new deployment.
* `--no-validate`: (*Default*: `false`) Skip validation.


---
## hal config metric-stores prometheus

Expand All @@ -6108,7 +6182,7 @@ hal config metric-stores prometheus [parameters] [subcommands]

#### Subcommands
* `disable`: Set the prometheus method as disabled
* `edit`: Edit the prometheus authentication method.
* `edit`: Edit the prometheus metric store.
* `enable`: Set the prometheus method as enabled

---
Expand All @@ -6129,7 +6203,7 @@ hal config metric-stores prometheus disable [parameters]
---
## hal config metric-stores prometheus edit

Edit the prometheus authentication method.
Edit the prometheus metric store.

#### Usage
```
Expand Down Expand Up @@ -6173,7 +6247,7 @@ hal config metric-stores stackdriver [parameters] [subcommands]

#### Subcommands
* `disable`: Set the stackdriver method as disabled
* `edit`: Edit the stackdriver authentication method.
* `edit`: Edit the stackdriver metric store.
* `enable`: Set the stackdriver method as enabled

---
Expand All @@ -6194,7 +6268,7 @@ hal config metric-stores stackdriver disable [parameters]
---
## hal config metric-stores stackdriver edit

Edit the stackdriver authentication method.
Edit the stackdriver metric store.

#### Usage
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.beust.jcommander.Parameters;
import com.netflix.spinnaker.halyard.cli.command.v1.config.metricStores.EditMetricStoresCommand;
import com.netflix.spinnaker.halyard.cli.command.v1.config.metricStores.datadog.DatadogCommand;
import com.netflix.spinnaker.halyard.cli.command.v1.config.metricStores.newrelic.NewrelicCommand;
import com.netflix.spinnaker.halyard.cli.command.v1.config.metricStores.prometheus.PrometheusCommand;
import com.netflix.spinnaker.halyard.cli.command.v1.config.metricStores.stackdriver.StackdriverCommand;
import com.netflix.spinnaker.halyard.cli.services.v1.Daemon;
Expand All @@ -45,6 +46,7 @@ public class MetricStoresCommand extends AbstractConfigCommand {
public MetricStoresCommand() {
registerSubcommand(new EditMetricStoresCommand());
registerSubcommand(new DatadogCommand());
registerSubcommand(new NewrelicCommand());
registerSubcommand(new PrometheusCommand());
registerSubcommand(new StackdriverCommand());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public abstract class AbstractEditMetricStoreCommand<T extends MetricStore>
protected abstract MetricStore editMetricStore(T metricStore);

public String getShortDescription() {
return "Edit the " + getMetricStoreType().getId() + " authentication method.";
return "Edit the " + getMetricStoreType().getId() + " metric store.";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* Copyright 2019 New Relic Corporation. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package com.netflix.spinnaker.halyard.cli.command.v1.config.metricStores.newrelic;

import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import com.netflix.spinnaker.halyard.cli.command.v1.config.metricStores.AbstractEditMetricStoreCommand;
import com.netflix.spinnaker.halyard.config.model.v1.metricStores.newrelic.NewrelicStore;
import com.netflix.spinnaker.halyard.config.model.v1.node.MetricStore;
import com.netflix.spinnaker.halyard.config.model.v1.node.MetricStores;
import java.util.ArrayList;
import java.util.List;

@Parameters(separators = "=")
public class EditNewrelicCommand extends AbstractEditMetricStoreCommand<NewrelicStore> {
public MetricStores.MetricStoreType getMetricStoreType() {
return MetricStores.MetricStoreType.NEWRELIC;
}

@Parameter(names = "--insert-key", description = "Your New Relic Insights insert key")
private String insertKey;

@Parameter(
names = "--host",
description =
"The URL to post metric data to. In almost all cases, this is set correctly by default and should not be used.")
private String host;

@Parameter(
names = "--tags",
variableArity = true,
description =
"Your custom tags. Please delimit the KVP with colons i.e. --tags app:test env:dev")
private List<String> tags = new ArrayList<>();

@Parameter(
names = "--add-tag",
description =
"Add this tag to the list of tags. Use the format key:value i.e. --add-tag app:test")
private String addTag;

@Parameter(
names = "--remove-tag",
description =
"Remove this tag from the list of tags. Use the name of the tag you want to remove i.e. --remove-tag app")
private String removeTag;

@Override
protected MetricStore editMetricStore(NewrelicStore newrelicStore) {
newrelicStore.setInsertKey(isSet(insertKey) ? insertKey : newrelicStore.getInsertKey());
newrelicStore.setHost(isSet(host) ? host : newrelicStore.getHost());

try {
newrelicStore.setTags(updateStringList(newrelicStore.getTags(), tags, addTag, removeTag));
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("Set either --tags or --[add/remove]-tag");
}

return newrelicStore;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright 2019 New Relic Corporation. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package com.netflix.spinnaker.halyard.cli.command.v1.config.metricStores.newrelic;

import com.beust.jcommander.Parameters;
import com.netflix.spinnaker.halyard.cli.command.v1.config.metricStores.MetricStoreCommand;
import com.netflix.spinnaker.halyard.config.model.v1.node.MetricStores;

@Parameters(separators = "=")
public class NewrelicCommand extends MetricStoreCommand {
public MetricStores.MetricStoreType getMetricStoreType() {
return MetricStores.MetricStoreType.NEWRELIC;
}

public NewrelicCommand() {
super();
registerSubcommand(new EditNewrelicCommand());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright 2019 New Relic Corporation. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package com.netflix.spinnaker.halyard.config.model.v1.metricStores.newrelic;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.netflix.spinnaker.halyard.config.model.v1.node.MetricStore;
import com.netflix.spinnaker.halyard.config.model.v1.node.MetricStores;
import com.netflix.spinnaker.halyard.config.model.v1.node.Secret;
import java.util.ArrayList;
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;

@EqualsAndHashCode(callSuper = true)
@Data
public class NewrelicStore extends MetricStore {
@Override
public String getNodeName() {
return "newrelic";
}

@JsonIgnore
private MetricStores.MetricStoreType metricStoreType = MetricStores.MetricStoreType.NEWRELIC;

@Secret(alwaysDecrypt = true)
@JsonProperty("insert_key")
private String insertKey;

@JsonProperty("host")
private String host;

@JsonProperty("tags")
private List<String> tags = new ArrayList<>();
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package com.netflix.spinnaker.halyard.config.model.v1.node;

import com.netflix.spinnaker.halyard.config.model.v1.metricStores.datadog.DatadogStore;
import com.netflix.spinnaker.halyard.config.model.v1.metricStores.newrelic.NewrelicStore;
import com.netflix.spinnaker.halyard.config.model.v1.metricStores.prometheus.PrometheusStore;
import com.netflix.spinnaker.halyard.config.model.v1.metricStores.stackdriver.StackdriverStore;
import java.lang.reflect.Field;
Expand All @@ -33,10 +34,14 @@ public class MetricStores extends Node {
private DatadogStore datadog = new DatadogStore();
private PrometheusStore prometheus = new PrometheusStore();
private StackdriverStore stackdriver = new StackdriverStore();
private NewrelicStore newrelic = new NewrelicStore();
private int period = 30;

public boolean isEnabled() {
return datadog.isEnabled() || prometheus.isEnabled() || stackdriver.isEnabled();
return datadog.isEnabled()
|| prometheus.isEnabled()
|| stackdriver.isEnabled()
|| newrelic.isEnabled();
}

public void setEnabled(boolean ignored) {}
Expand Down Expand Up @@ -64,7 +69,8 @@ public static Class<? extends MetricStore> translateMetricStoreType(String metri
public enum MetricStoreType {
DATADOG("datadog"),
PROMETHEUS("prometheus"),
STACKDRIVER("stackdriver");
STACKDRIVER("stackdriver"),
NEWRELIC("newrelic");

@Getter private final String id;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package com.netflix.spinnaker.halyard.config.services.v1;

import com.netflix.spinnaker.halyard.config.model.v1.metricStores.datadog.DatadogStore;
import com.netflix.spinnaker.halyard.config.model.v1.metricStores.newrelic.NewrelicStore;
import com.netflix.spinnaker.halyard.config.model.v1.metricStores.prometheus.PrometheusStore;
import com.netflix.spinnaker.halyard.config.model.v1.metricStores.stackdriver.StackdriverStore;
import com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration;
Expand Down Expand Up @@ -111,6 +112,9 @@ public void setMetricStore(String deploymentName, MetricStore metricStore) {
case DATADOG:
metricStores.setDatadog((DatadogStore) metricStore);
break;
case NEWRELIC:
metricStores.setNewrelic((NewrelicStore) metricStore);
break;
case PROMETHEUS:
metricStores.setPrometheus((PrometheusStore) metricStore);
break;
Expand Down
Loading

0 comments on commit b4de6f0

Please sign in to comment.