Skip to content
This repository was archived by the owner on Oct 3, 2023. It is now read-only.

Commit f1b9ac1

Browse files
authored
Merge pull request #2 from ajilaag/develop
Develop
2 parents d2bdacf + f52cca3 commit f1b9ac1

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

Dockerfile

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ FROM golang:alpine
33
# Update
44
RUN apk update upgrade;
55

6+
# Install git
7+
RUN apk add git
8+
69
# Set timezone to Europe/Zurich
710
RUN apk add tzdata
811
RUN ln -s /usr/share/zoneinfo/Europe/Zurich /etc/localtime
@@ -21,6 +24,8 @@ RUN freshclam --quiet --no-dns
2124

2225
# Build go package
2326
ADD . /go/src/clamav-rest/
27+
RUN go get github.com/dutchcoders/go-clamd
28+
RUN go get github.com/prometheus/client_golang/prometheus/promhttp
2429
ADD ./server.* /etc/ssl/clamav-rest/
2530
RUN cd /go/src/clamav-rest && go build -v
2631

README.md

+12-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
- [Configuration](#configuration)
99
- [Environment Variables](#environment-variables)
1010
- [Networking](#networking)
11-
- [Maintenance](#maintenance)
11+
- [Maintenance / Monitoring](#maintenance--monitoring)
1212
- [Shell Access](#shell-access)
13+
1314
- [Developing](#developing)
1415
- [References](#references)
1516

@@ -134,7 +135,7 @@ Below is the complete list of available options that can be used to customize yo
134135
|-----------|-------------|
135136
| `3310` | ClamD Listening Port |
136137
137-
# Maintenance
138+
# Maintenance / Monitoring
138139
139140
## Shell Access
140141
@@ -143,6 +144,15 @@ For debugging and maintenance purposes you may want access the containers shell.
143144
```bash
144145
docker exec -it (whatever your container name is e.g. clamav-rest) /bin/sh
145146
```
147+
## Prometheus
148+
149+
[Prometheus metrics](https://prometheus.io/docs/guides/go-application/) were implemented, which can be retrieved as follows
150+
151+
**HTTP**:
152+
curl http://localhost:9000/metrics
153+
154+
**HTTPS:**
155+
curl https://localhost:9443/metrics
146156
147157
# Developing
148158

clamrest.go

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"time"
1313

1414
"github.com/dutchcoders/go-clamd"
15+
"github.com/prometheus/client_golang/prometheus/promhttp"
1516
)
1617

1718
var opts map[string]string
@@ -184,6 +185,9 @@ func main() {
184185
http.HandleFunc("/scanPath", scanPathHandler)
185186
http.HandleFunc("/", home)
186187

188+
// Prometheus metrics
189+
http.Handle("/metrics", promhttp.Handler())
190+
187191
// Start the HTTPS server in a goroutine
188192
go http.ListenAndServeTLS(SSL_PORT, "/etc/ssl/clamav-rest/server.crt", "/etc/ssl/clamav-rest/server.key", nil)
189193

0 commit comments

Comments
 (0)