Name: mdg
Owner: Mackerel
Description: mdg - Mackerel Dashboard Generator
Created: 2015-09-01 10:14:21.0
Updated: 2015-10-26 02:02:51.0
Pushed: 2015-09-03 10:37:45.0
Size: 174
Language: Ruby
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
mdg - Mackerel Dashboard Generator
mdg
is a small script to help generating markdown for custom dashboard in Mackerel.
The script generates a markdown which contains embedded graphs of specified service and role.
It's written in Ruby.
g -o <orgName> -s <serviceName> -r <roleName> [ -f <config file(yaml)> ]
g -o SampleOrg -s SampleService -r backend
d
loadavg5
1w|1mo|
|:--|:--|
rame src='https://mackerel.io/embed/orgs/SampleOrg/services/SampleService/backend?graph=loadavg5&period=1d' height='200' width='400' frameborder='0'></iframe>|<iframe src='https://mackerel.io/embed/orgs/SampleOrg/services/SampleService/backend?graph=loadavg5&period=1w' height='200' width='400' frameborder='0'></iframe>|<iframe src='https://mackerel.io/embed/orgs/SampleOrg/services/SampleService/backend?graph=loadavg5&period=1mo' height='200' width='400' frameborder='0'></iframe>|
cpu.{user,iowait,system}
1w|1mo|
|:--|:--|
rame src='https://mackerel.io/embed/orgs/SampleOrg/services/SampleService/backend?graph=cpu.%7Buser%2Ciowait%2Csystem%7D&period=1d' height='200' width='400' frameborder='0'></iframe>|<iframe src='https://mackerel.io/embed/orgs/SampleOrg/services/SampleService/backend?graph=cpu.%7Buser%2Ciowait%2Csystem%7D&period=1w' height='200' width='400' frameborder='0'></iframe>|<iframe src='https://mackerel.io/embed/orgs/SampleOrg/services/SampleService/backend?graph=cpu.%7Buser%2Ciowait%2Csystem%7D&period=1mo' height='200' width='400' frameborder='0'></iframe>|
ods:
1d
1w
1mo
h_names:
loadavg5
cpu.user
h_size:
ight: 200
dth: 600
|name |description |default | |— |— |— | |periods |List of period of graph |[“1d”, “1w”, “1mo”] | |graph_names|Names of the graphs that will be generated |all basic graphs | |graph_size |Size of the graph |height:200, width:400|
There are 6 types of time fields as follow.
You can concatenate multiple fields to specify the values of periods
.
For example, 10w6h30m
means 10 weeks and 6 hours and 30 minutes
.
mdg
assisted by pecosr/bin/env sh
SCRIPTION:
ample script for using mdg with peco
PENDENCIES:
curl http://curl.haxx.se/
jq https://github.com/stedolan/jq
peco https://github.com/peco/peco
-z "$MACKEREL_API_BASE" ]; then
CKEREL_API_BASE="https://mackerel.io/api/v0"
-z "$MACKEREL_APIKEY" ]; then
CKEREL_APIKEY="" # Write API key
-z "$MACKEREL_ORG_NAME" ]; then
CKEREL_ORG_NAME="" # Write organization name
erel_api() {
[ -n "$1" ]; then
curl -s -H "X-Api-Key: $1" "$MACKEREL_API_BASE$2"
se
echo 'API key is empty' 1>&2
return 1
erel_services() {
ckerel_api "$MACKEREL_APIKEY" "/services" | jq -a -M -r '.services[].name'
erel_roles() {
ckerel_api "$MACKEREL_APIKEY" "/services/$1/roles" | jq -a -M -r '.roles[].name'
-z "$MACKEREL_APIKEY" ]; then
ho 'API key is empty.' 1>&2
it 1
ice=$(mackerel_services | peco)
=$(mackerel_roles $service | peco)
$# -gt 0 ] ; then
nfig_file=$1
g -o ${MACKEREL_ORG_NAME} -s ${service} -r ${role} -f $config_file
g -o ${MACKEREL_ORG_NAME} -s ${service} -r ${role}
Please export MACKEREL_APIKEY
and MACKEREL_ORG_NAME
, or write them directly in the above script.
You can use an api key which does not have the write permission.
port MACKEREL_APIKEY="API KEY"
port MACKEREL_ORG_NAME="YOUR ORGANIZATION NAME"
You can specify the service and the role with peco by executing this script
/path/to/mdg_peco
you can pass config file
/path/to/mdg_peco /path/to/config.yaml
Copyright 2015 Hatena Co., Ltd.
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.