forked from grafana-cold-storage/metrictank
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig-to-doc.sh
More file actions
executable file
·110 lines (84 loc) · 2.61 KB
/
Copy pathconfig-to-doc.sh
File metadata and controls
executable file
·110 lines (84 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/bash
# turns the metrictank-sample.ini into a nice markdown document.
# headers like h3 and h2 are printed as-is, and the lines between them (config items and their comments)
# are wrapped in ``` blocks. t=code means we're in such a block.
# Find the directory we exist within and cd into the root level dir
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
cd ${DIR}/../..
function process() {
local filename="$1"
t=
while read line; do
# skip empty lines
if [ "$line" == "" ]; then
continue
fi
if [[ "$line" =~ ^### ]]; then
if [ "$t" == code ]; then
echo '```'
echo
fi
echo "$line"
t=h3
elif [[ "$line" =~ ^## ]]; then
if [ "$t" == code ]; then
echo '```'
echo
fi
echo "$line"
t=h2
else
if [ "$t" == h2 -o "$t" == h3 ]; then
echo -e '\n```'
t=code
fi
# lines that start with a pound are fine within code blocks,
# but outside of code blocks, would be shown as headers, which is not how they are intended
# in the source file they are just regular comments too, so take away their #
#if [[ "$line" =~ ^# ]]; then
if [[ "$t" != code ]]; then
sed -e 's/^# //' -e 's/$/ /'<<< "$line"
else
echo "$line"
fi
fi
done < "$filename"
# finish of pending code block
if [ "$t" == code ]; then
echo '```'
fi
}
cat << EOF
# Config
Metrictank comes with an [example main config file](https://github.com/grafana/metrictank/blob/master/metrictank-sample.ini),
a [storage-schemas.conf file](https://github.com/grafana/metrictank/blob/master/scripts/config/storage-schemas.conf) and
a [storage-aggregation.conf file](https://github.com/grafana/metrictank/blob/master/scripts/config/storage-aggregation.conf)
The files themselves are well documented, but for your convenience, they are replicated below.
Config values for the main ini config file can also be set, or overridden via environment variables.
They require the 'MT_' prefix. Any delimiter is represented as an underscore.
Settings within section names in the config just require you to prefix the section header.
Examples:
\`\`\`
MT_LOG_LEVEL: 1 # MT_<setting_name>
MT_CASSANDRA_WRITE_CONCURRENCY: 10 # MT_<setting_name>
MT_KAFKA_MDM_IN_DATA_DIR: /your/data/dir # MT_<section_title>_<setting_name>
\`\`\`
---
# Metrictank.ini
EOF
process metrictank-sample.ini
cat << EOF
# storage-schemas.conf
\`\`\`
EOF
cat scripts/config/storage-schemas.conf
cat << EOF
\`\`\`
# storage-aggregation.conf
\`\`\`
EOF
cat scripts/config/storage-aggregation.conf
cat << EOF
\`\`\`
This file is generated by [config-to-doc](https://github.com/grafana/metrictank/blob/master/scripts/dev/config-to-doc.sh)
EOF