Skip to content

Commit b9a4070

Browse files
committed
improved
1 parent 6e2d85d commit b9a4070

File tree

3 files changed

+14
-37
lines changed

3 files changed

+14
-37
lines changed

Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ COPY .build/${OS}-${ARCH}/aws_cloudwatch_exporter /bin/aws_cloudwatch_exporter
1818
ARG PORT="9690"
1919
EXPOSE ${PORT}
2020

21-
USER nobody
21+
RUN mkdir -p /home/nobody/.aws && chown -R nobody.nogroup /home/nobody
22+
ENV HOME="/home/nobody"
23+
USER nobody
2224

2325
HEALTHCHECK CMD wget --spider -S "http://localhost:${PORT}/health" -T 60 2>&1 || exit 1
2426

25-
VOLUME ["/metrics","/home/nobody"]
27+
VOLUME ["/home/nobody"]
2628

2729
ENTRYPOINT [ "/bin/aws_cloudwatch_exporter" ]
2830
# CMD [ "/bin/aws_cloudwatch_exporter" ]

README.md

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -25,41 +25,16 @@ the same configuration key is defined as a `Env Var` this last will replace the
2525
#### Docker
2626

2727
```bash
28-
make && \
29-
make promu && \
30-
promu build --prefix .build/darwin-amd64 && \
31-
make docker DOCKER_REPO=docker.io/slashdevops
32-
3328
docker run --rm \
34-
-v ~/tmp/queries/m1.yaml:/metrics/m1.yaml \
35-
-v ~/.aws:/credentials \
36-
-v ~/.aws:/credentials \
29+
-i \
30+
-u nobody:nogroup \
31+
--privileged \
32+
-v ~/tmp/queries/m1.yaml:/home/nobody/m1.yaml:ro \
33+
-v /tmp/:/home/nobody/tmp/:rw \
34+
-v ~/.aws:/home/nobody/.aws:ro \
3735
-e "AWS_SDK_LOAD_CONFIG=1" \
38-
-e "AWS_CONFIG_FILE=/credentials/.aws/config" \
39-
-e "AWS_SHARED_CREDENTIALS_FILE=/credentials/.aws/credentials" \
40-
-e "AWS_PROFILE=slashdevops" \
41-
slashdevops/aws-cloudwatch-exporter-linux-amd64:develop metrics get --metricsFiles /metrics/m1.yaml \
42-
--debug
43-
44-
docker run --rm \
45-
-v ~/tmp/queries/m1.yaml:/metrics/m1.yaml \
46-
-v ~/.aws/credentials:/home/.aws/credentials:ro \
47-
-v ~/.aws/config:/home/.aws/config:ro \
4836
-e "AWS_PROFILE=slashdevops" \
49-
slashdevops/aws-cloudwatch-exporter-linux-amd64:develop metrics get --metricsFiles /metrics/m1.yaml \
50-
--debug
51-
52-
docker run --rm \
53-
-v ~/tmp/queries/m1.yaml:/metrics/m1.yaml \
54-
-e "AWS_REGION=eu-west-1" \
55-
slashdevops/aws-cloudwatch-exporter-linux-amd64:develop metrics get --metricsFiles /metrics/m1.yaml \
56-
--debug
57-
58-
docker run --rm \
59-
-v ~/tmp/queries/m1.yaml:/metrics/m1.yaml \
60-
-v $HOME/.aws/credentials:/home/nobody/.aws/credentials -u nobody \
61-
-v $HOME/.aws/config:/home/nobody/.aws/config -u nobody \
62-
slashdevops/aws-cloudwatch-exporter-linux-amd64:develop ls -la /home/nobody/
37+
slashdevops/aws-cloudwatch-exporter-linux-amd64:develop metrics get --metricsFiles /home/nobody/m1.yaml --outFile /home/nobody/tmp/out.yaml
6338
```
6439

6540
#### Binary

cmd/metrics.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ func init() {
9797
metricsGetCmd.Flags().StringP("outFormat", "", "yaml", "Output format for results, possible values: [yaml|json]")
9898
metricsGetCmd.Flags().StringP("outFile", "", "", "Output file where to store the results.")
9999

100-
metricsCollectCmd.Flags().StringP("address", "", "127.0.0.1", "Server address, empty means all addresses")
101-
metricsCollectCmd.Flags().StringP("port", "", "8080", "Server port")
100+
metricsCollectCmd.Flags().StringP("address", "", appIP, "Server address, empty means all addresses")
101+
metricsCollectCmd.Flags().Uint16P("port", "", appPort, "Server port")
102102
}
103103

104104
func getCmd(cmd *cobra.Command, args []string) {
@@ -228,7 +228,7 @@ func collectCmd(cmd *cobra.Command, args []string) {
228228
})
229229

230230
a, _ := cmd.Flags().GetString("address")
231-
p, _ := cmd.Flags().GetString("port")
231+
p, _ := cmd.Flags().GetUint16("port")
232232
soc := fmt.Sprintf("%s:%v", a, p)
233233

234234
log.Infof("Starting test server on %s", soc)

0 commit comments

Comments
 (0)