Skip to content

Commit 484f712

Browse files
authored
Merge branch 'main' into add-code-coverage-integration
2 parents f60d9db + 73fd414 commit 484f712

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+3469
-1725
lines changed

.github/workflows/go.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,15 @@ jobs:
2222
image:
2323
- mongo:4.4
2424
- mongo:5.0
25+
- mongo:6.0
26+
- mongo:7.0
27+
- mongo:8.0
28+
- mongo:latest
2529
- percona/percona-server-mongodb:4.4
2630
- percona/percona-server-mongodb:5.0
31+
- percona/percona-server-mongodb:6.0
32+
- percona/percona-server-mongodb:7.0
33+
- percona/percona-server-mongodb:latest
2734

2835
runs-on: ubuntu-latest
2936

@@ -32,7 +39,7 @@ jobs:
3239
uses: actions/checkout@v4
3340

3441
- name: Set up Go
35-
uses: actions/setup-go@v4
42+
uses: actions/setup-go@v5
3643
with:
3744
go-version-file: ${{ github.workspace }}/go.mod
3845

@@ -43,10 +50,25 @@ jobs:
4350
make test-cover
4451
make test-cluster-clean
4552
53+
4654
- name: Upload coverage results
4755
uses: codecov/codecov-action@v3
4856
with:
4957
file: cover.out
5058
flags: agent
5159
env_vars: GO_VERSION,TEST_MONGODB_IMAGE
5260
fail_ci_if_error: false
61+
62+
- name: Run debug commands on failure
63+
if: ${{ failure() }}
64+
run: |
65+
echo "--- Environment variables ---"
66+
env | sort
67+
echo "--- GO Environment ---"
68+
go env | sort
69+
echo "--- Git status ---"
70+
git status
71+
echo "--- Docker logs ---"
72+
docker compose logs
73+
echo "--- Docker ps ---"
74+
docker compose ps -a

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
uses: actions/checkout@v4
2424

2525
- name: Set up Go
26-
uses: actions/setup-go@v4
26+
uses: actions/setup-go@v5
2727
with:
2828
go-version-file: ${{ github.workspace }}/go.mod
2929

.github/workflows/release.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
fetch-depth: 0
1919

2020
- name: Set up Go
21-
uses: actions/setup-go@v4
21+
uses: actions/setup-go@v5
2222
with:
2323
go-version-file: ${{ github.workspace }}/go.mod
2424

@@ -43,9 +43,9 @@ jobs:
4343
uses: docker/setup-buildx-action@v3
4444

4545
- name: Run GoReleaser
46-
uses: goreleaser/goreleaser-action@v5
46+
uses: goreleaser/goreleaser-action@v6
4747
with:
48-
version: v1.18.2
49-
args: release --rm-dist
48+
version: "~> v2"
49+
args: release --clean
5050
env:
5151
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.goreleaser.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
dist: build
2+
version: 2
23
builds:
34
- binary: mongodb_exporter
45
env:
56
- CGO_ENABLED=0
67
goos:
78
- linux
89
- darwin
10+
- windows
911
goarch:
1012
- amd64
1113
- arm
@@ -23,9 +25,9 @@ archives:
2325
- name_template: "{{ .ProjectName }}-{{ .Version }}.{{ .Os }}-{{ .Arch }}"
2426
wrap_in_directory: true
2527
snapshot:
26-
name_template: "{{ .ShortCommit }}"
28+
version_template: "{{ .ShortCommit }}"
2729
changelog:
28-
skip: true
30+
use: github
2931
release:
3032
github:
3133
owner: percona
@@ -77,8 +79,9 @@ docker_manifests:
7779
image_templates:
7880
- ghcr.io/percona/mongodb_exporter:{{.Version}}-arm64v8
7981
- ghcr.io/percona/mongodb_exporter:{{.Version}}-amd64
82+
8083
nfpms:
81-
- file_name_template: "{{ .ProjectName }}-{{ .Version }}.{{ .Os }}-{{ .Arch }}"
84+
- file_name_template: "{{ .ProjectName }}-{{ .Version }}.{{ .Os }}-{{- if eq .Arch `amd64` }}64-bit{{- else }}{{ .Arch }}{{ end }}"
8285
homepage: https://www.percona.com/
8386
description: MongoDB exporter for Prometheus
8487
maintainer: Percona
@@ -88,8 +91,6 @@ nfpms:
8891
- deb
8992
- rpm
9093
bindir: /usr/bin
91-
replacements:
92-
amd64: 64-bit
9394
scripts:
9495
postinstall: ".scripts/postinst"
9596
contents:

CHANGELOG

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1+
Release 0.41.1
2+
- Fix panic (regression bug in v0.41.0) occuring when fcv collector is enabled
3+
4+
Release 0.41.0
5+
6+
- Add extra label for replicaset metrics
7+
- Add information about supported MongoDB versions
8+
- Add command line flag to disable metrics about the exporter it-self
9+
- Add PBM metrics collector
10+
- Add cluster role label for mongodb_up
11+
- Add feature compatibility version collector
12+
- Migrate chunks metrics from v1 compatibility to shards collector
13+
- Correctly recognize arbiter nodes
14+
- Fix node type detection
15+
- Collstats, indexstats iterate only over collections, not views.
16+
- Fix case where users are prefixed with mongodb
17+
- Reconsider inclusion of opid in mongodb_currentop_query_uptime
18+
- List only authorized collections
19+
- Correctly evaluate balancer metrics
20+
- Reduce error logs from diagnostic data on arbiter nodes
21+
- Refactoring currentop_collector
22+
- Remove system colections from index stats
23+
- Update Go version
24+
- Update dependencies
25+
126
Release 0.40.0
227

328
- Multi-target support

CONTRIBUTING.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,24 @@ It will install `goimports`, `goreleaser`, `golangci-lint` and `reviewdog`.
9191

9292
The testing sandbox starts `n` MongoDB instances as follows:
9393

94-
- 3 Instances for shard 1 at ports 17001, 17002, 17003
95-
- 3 instances for shard 2 at ports 17004, 17005, 17006
94+
- 3 Instances for shard 1 at ports 17001, 17002, 17003 (with no authentication)
95+
- 3 instances for shard 2 at ports 17004, 17005, 17006 (with authentication enabled)
9696
- 3 config servers at ports 17007, 17008, 17009
9797
- 1 mongos server at port 17000
9898
- 1 stand alone instance at port 27017
9999

100-
All instances are currently running without user and password so for example, to connect to the **mongos** you can just use:
100+
To connect to the **mongos** on shard 1, you can use:
101101

102102
```
103103
mongo mongodb://127.0.0.1:17001/admin
104104
```
105105

106+
To connect to the **mongos** on shard 2 (with authentication enabled), you can use:
107+
108+
```
109+
mongo mongodb://admin:[email protected]:17001/admin
110+
```
111+
106112
The sandbox can be started using the provided Makefile using: `make test-cluster` and it can be stopped using `make test-cluster-clean`.
107113

108114
### Running tests

Makefile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ REPO ?= percona/$(NAME)
1717
GORELEASER_FLAGS ?=
1818
UID ?= $(shell id -u)
1919

20-
export TEST_MONGODB_IMAGE?=mongo:4.2
20+
export TEST_MONGODB_IMAGE?=mongo:4.4
2121
export TEST_MONGODB_ADMIN_USERNAME?=
2222
export TEST_MONGODB_ADMIN_PASSWORD?=
2323
export TEST_MONGODB_USERNAME?=
@@ -76,8 +76,9 @@ build: ## Compile using plain go build
7676
release: ## Build the binaries using goreleaser
7777
docker run --rm --privileged \
7878
-v ${PWD}:/go/src/github.com/user/repo \
79+
-v /var/run/docker.sock:/var/run/docker.sock \
7980
-w /go/src/github.com/user/repo \
80-
goreleaser/goreleaser release --snapshot --skip-publish --rm-dist
81+
goreleaser/goreleaser release --snapshot --skip=publish --clean
8182

8283
FILES = $(shell find . -type f -name '*.go' -not -path "./vendor/*")
8384

@@ -107,7 +108,8 @@ test-cover: env ## Run tests and collect cross-package coverage inf
107108
go test -race -timeout 30s -coverprofile=cover.out -covermode=atomic -coverpkg=./... ./...
108109

109110
test-cluster: env ## Starts MongoDB test cluster. Use env var TEST_MONGODB_IMAGE to set flavor and version. Example: TEST_MONGODB_IMAGE=mongo:3.6 make test-cluster
110-
docker compose up -d --wait
111+
docker compose up --build -d
112+
./docker/scripts/setup-pbm.sh
111113

112114
test-cluster-clean: env ## Stops MongoDB test cluster.
113-
docker compose down --remove-orphans --volumes --timeout 1
115+
docker compose down --remove-orphans --volumes

README.md

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ Currently, these metric sources are implemented:
1616
- replSetGetStatus
1717
- serverStatus
1818

19+
## Supported MongoDB versions
20+
21+
The exporter works with Percona Server for MongoDB and MongoDB Community or Enterprise Edition versions 4.4 and newer. Older versions might also work but are not tested anymore.
22+
1923
## Info on Percona MongoDB exporter versions
2024

2125
The old 0.1x.y version (ex `master` branch) has been moved to the `release-0.1x` branch.
@@ -48,10 +52,10 @@ A docker image is available on the [official percona repository](https://hub.doc
4852

4953
```sh
5054
# with podman
51-
podman run -d -p 9216:9216 -p 17001:17001 percona/mongodb_exporter:0.20 --mongodb.uri=mongodb://127.0.0.1:17001
55+
podman run -d -p 9216:9216 percona/mongodb_exporter:0.40 --mongodb.uri=mongodb://127.0.0.1:17001
5256

5357
# with docker
54-
docker run -d -p 9216:9216 -p 17001:17001 percona/mongodb_exporter:0.20 --mongodb.uri=mongodb://127.0.0.1:17001
58+
docker run -d -p 9216:9216 percona/mongodb_exporter:0.40 --mongodb.uri=mongodb://127.0.0.1:17001
5559
```
5660

5761
#### Permissions
@@ -91,11 +95,28 @@ You can run the exporter specifying multiple URIs, devided by a comma in --mongo
9195
```sh
9296
--mongodb.uri=mongodb://user:[email protected]:27017/admin,mongodb://user2:[email protected]:27018/admin
9397
```
94-
In this case you can use the **/scrape** endpoint with the **target** parameter to retreive the specified tartget's metrics. When querying the data you can use just mongodb://host:port in the targer parameter without other parameters and, of course without host credentials
98+
In this case you can use the **/scrape** endpoint with the **target** parameter to retreive the specified tartget's metrics. When querying the data you can use just mongodb://host:port in the target parameter without other parameters and, of course without host credentials
9599
```sh
96100
GET /scrape?target=mongodb://127.0.0.1:27018
97101
```
102+
If your URI is prefixed by mongodb:// or mongodb+srv:// schema, any host not prefixed by it after comma is being treated as part of a cluster rather then as a standalone host. Thus clusters and standalone hosts can be combined like this:
103+
```
104+
--mongodb.uri=mongodb+srv://user:pass@host1:27017,host2:27017,host3:27017/admin,mongodb://user2:pass2@host4:27018/admin
105+
```
106+
107+
You can use the --split-cluster option to split all cluster nodes into separate targets. This mode is useful when cluster nodes are defined as SRV records and the mongodb_exporter is running with mongodb+srv domain specified. In this case SRV records will be queried upon mongodb_exporter start and each cluster node can be queried using the **target** parameter of multitarget endpoint.
108+
109+
#### Overall targets request endpoint
98110

111+
There is an overall targets endpoint **/scrapeall** that queries all the targets in one request. It can be used to store multiple node metrics without separate target requests. In this case, each node metric will have a **instance** label containing the node name as a host:port pair (or just host if no port was not specified). For example, for mongodb_exporter running with the options:
112+
```
113+
--mongodb.uri="mongodb://host1:27015,host2:27016" --split-cluster=true
114+
```
115+
we get metrics like this:
116+
```
117+
mongodb_up{instance="host1:27015"} 1
118+
mongodb_up{instance="host2:27016"} 1
119+
```
99120

100121
#### Enabling collstats metrics gathering
101122
`--mongodb.collstats-colls` receives a list of databases and collections to monitor using collstats.
@@ -128,6 +149,17 @@ Usage example: `db.setProfilingLevel(2)`
128149
|1| The profiler collects data for operations that take longer than the value of `slowms` or that match a filter.<br> When a filter is set: <ul><li> The `slowms` and `sampleRate` options are not used for profiling.</li><li>The profiler only captures operations that match the filter.</li></ul>
129150
|2|The profiler collects data for all operations.|
130151

152+
#### Enabling shards metrics gathering
153+
When shard metrics collection is enabled by `--collector.shards`, the exporter will expose metrics related to sharded Mongo.
154+
Example, if shards collector is enabled:
155+
```
156+
# HELP mongodb_shards_collection_chunks_count sharded collection chunks.
157+
# TYPE mongodb_shards_collection_chunks_count counter
158+
mongodb_shards_collection_chunks_count{collection="system.sessions",database="config",shard="rs1"} 250
159+
mongodb_shards_collection_chunks_count{collection="system.sessions",database="config",shard="rs2"} 250
160+
```
161+
You can see shard name, it's collection, database and count.
162+
131163
#### Cluster role labels
132164
The exporter sets some topology labels in all metrics.
133165
The labels are:

0 commit comments

Comments
 (0)