Skip to content

Instantly share code, notes, and snippets.

@eddiewebb
Created December 11, 2018 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eddiewebb/d9cafa131de36a9e2f08e1db90a3745e to your computer and use it in GitHub Desktop.
Save eddiewebb/d9cafa131de36a9e2f08e1db90a3745e to your computer and use it in GitHub Desktop.
Add Custom Metrics Manually to CircleCI Server
#!/bin/bash
#
# This script is a workaround to a Replicated issue in which the configuration sections do not appear in the admin console.
# It should be run on the services box from a new/clean directory where a backup will be created.
#
if [ ! -f metrics.txt ];then
echo "Please run this script in a clean directory with a 'metrics.txt' file containing desired telegraf config"
exit 1
fi
# install JQ, a json manipulation tool (must be version 1.5+)
curl -L https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64 -o jq
chmod a+x jq
sudo mv jq /usr/bin
jq --version
# backup existing config, augment with metrics, and pipe back into config import
replicatedctl app-config export | tee backup.json | jq --arg metrics "$(<metrics.txt)" '. += {"custom_metrics_enabled": {"value": "1"},"custom_telegraf_config": {"value":$metrics}}' | replicatedctl app-config import
[[outputs.cloudwatch]]
region = 'us-east-2'
namespace = 'eddies-autoscale-metrics'
namepass = [
'circle.nomad.server_agent.*'
]
[[outputs.datadog]]
apikey = 'YOURKEY'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment