Skip to content

Commit 09d268f

Browse files
authored
Merge pull request #26 from sysdiglabs/master
Master fetch
2 parents e05e2b7 + 9b1dbdd commit 09d268f

34 files changed

+1477
-218
lines changed

.circleci/config.yml

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,20 @@
11
---
22
version: 2.1
3-
43
orbs:
5-
prometheus: prometheus/prometheus@0.11.0
6-
4+
prometheus: prometheus/prometheus@0.16.0
75
executors:
86
# This must match .promu.yml.
97
golang:
108
docker:
11-
- image: circleci/golang:1.16
12-
9+
- image: cimg/go:1.18
1310
jobs:
1411
test:
1512
executor: golang
16-
1713
steps:
1814
- prometheus/setup_environment
1915
- run: make
2016
- prometheus/store_artifact:
2117
file: elasticsearch_exporter
22-
2318
workflows:
2419
version: 2
2520
elasticsearch_exporter:

.github/dependabot.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,8 @@ updates:
1111
schedule:
1212
interval: "daily"
1313
registries:
14-
- docker-registry-quay-io
14+
- docker-registry-quay-io
15+
- package-ecosystem: "gomod"
16+
directory: "/"
17+
schedule:
18+
interval: "monthly"

.github/workflows/golangci-lint.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: golangci-lint
2+
on:
3+
push:
4+
paths:
5+
- "go.sum"
6+
- "go.mod"
7+
- "**.go"
8+
- "scripts/errcheck_excludes.txt"
9+
- ".github/workflows/golangci-lint.yml"
10+
- ".golangci.yml"
11+
pull_request:
12+
13+
jobs:
14+
golangci:
15+
name: lint
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v3
20+
- name: install Go
21+
uses: actions/setup-go@v2
22+
with:
23+
go-version: 1.18.x
24+
- name: Install snmp_exporter/generator dependencies
25+
run: sudo apt-get update && sudo apt-get -y install libsnmp-dev
26+
if: github.repository == 'prometheus/snmp_exporter'
27+
- name: Lint
28+
uses: golangci/golangci-lint-action@v3.2.0
29+
with:
30+
version: v1.45.2

.golangci.yml

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
---
2+
linters:
3+
enable:
4+
- revive
5+
26
issues:
37
exclude-rules:
48
- path: _test.go

.promu.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
go:
22
# This must match .circle/config.yml.
3-
version: 1.16
3+
version: 1.18
44
repository:
55
path: github.com/prometheus-community/elasticsearch_exporter
66
build:

.yamllint

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
extends: default
3+
4+
rules:
5+
braces:
6+
max-spaces-inside: 1
7+
level: error
8+
brackets:
9+
max-spaces-inside: 1
10+
level: error
11+
commas: disable
12+
comments: disable
13+
comments-indentation: disable
14+
document-start: disable
15+
indentation:
16+
spaces: consistent
17+
indent-sequences: consistent
18+
key-duplicates:
19+
ignore: |
20+
config/testdata/section_key_dup.bad.yml
21+
line-length: disable
22+
truthy:
23+
ignore: |
24+
.github/workflows/codeql-analysis.yml
25+
.github/workflows/funcbench.yml
26+
.github/workflows/fuzzing.yml
27+
.github/workflows/prombench.yml
28+
.github/workflows/golangci-lint.yml

CODE_OF_CONDUCT.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
## Prometheus Community Code of Conduct
1+
# Prometheus Community Code of Conduct
22

3-
Prometheus follows the [CNCF Code of Conduct](https://github.com/cncf/foundation/blob/master/code-of-conduct.md).
3+
Prometheus follows the [CNCF Code of Conduct](https://github.com/cncf/foundation/blob/main/code-of-conduct.md).

MAINTAINERS.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
* Ben Kochie <superq@gmail.com> @SuperQ
2+
* Joe Adams <github@joeadams.io> @sysadmind

Makefile.common

+13-66
Original file line numberDiff line numberDiff line change
@@ -36,29 +36,6 @@ GO_VERSION ?= $(shell $(GO) version)
3636
GO_VERSION_NUMBER ?= $(word 3, $(GO_VERSION))
3737
PRE_GO_111 ?= $(shell echo $(GO_VERSION_NUMBER) | grep -E 'go1\.(10|[0-9])\.')
3838

39-
GOVENDOR :=
40-
GO111MODULE :=
41-
ifeq (, $(PRE_GO_111))
42-
ifneq (,$(wildcard go.mod))
43-
# Enforce Go modules support just in case the directory is inside GOPATH (and for Travis CI).
44-
GO111MODULE := on
45-
46-
ifneq (,$(wildcard vendor))
47-
# Always use the local vendor/ directory to satisfy the dependencies.
48-
GOOPTS := $(GOOPTS) -mod=vendor
49-
endif
50-
endif
51-
else
52-
ifneq (,$(wildcard go.mod))
53-
ifneq (,$(wildcard vendor))
54-
$(warning This repository requires Go >= 1.11 because of Go modules)
55-
$(warning Some recipes may not work as expected as the current Go runtime is '$(GO_VERSION_NUMBER)')
56-
endif
57-
else
58-
# This repository isn't using Go modules (yet).
59-
GOVENDOR := $(FIRST_GOPATH)/bin/govendor
60-
endif
61-
endif
6239
PROMU := $(FIRST_GOPATH)/bin/promu
6340
pkgs = ./...
6441

@@ -78,12 +55,12 @@ ifneq ($(shell which gotestsum),)
7855
endif
7956
endif
8057

81-
PROMU_VERSION ?= 0.12.0
58+
PROMU_VERSION ?= 0.13.0
8259
PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_VERSION)/promu-$(PROMU_VERSION).$(GO_BUILD_PLATFORM).tar.gz
8360

8461
GOLANGCI_LINT :=
8562
GOLANGCI_LINT_OPTS ?=
86-
GOLANGCI_LINT_VERSION ?= v1.42.0
63+
GOLANGCI_LINT_VERSION ?= v1.45.2
8764
# golangci-lint only supports linux, darwin and windows platforms on i386/amd64.
8865
# windows isn't included here because of the path separator being different.
8966
ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux darwin))
@@ -150,58 +127,47 @@ common-check_license:
150127
.PHONY: common-deps
151128
common-deps:
152129
@echo ">> getting dependencies"
153-
ifdef GO111MODULE
154-
GO111MODULE=$(GO111MODULE) $(GO) mod download
155-
else
156-
$(GO) get $(GOOPTS) -t ./...
157-
endif
130+
$(GO) mod download
158131

159132
.PHONY: update-go-deps
160133
update-go-deps:
161134
@echo ">> updating Go dependencies"
162135
@for m in $$($(GO) list -mod=readonly -m -f '{{ if and (not .Indirect) (not .Main)}}{{.Path}}{{end}}' all); do \
163136
$(GO) get -d $$m; \
164137
done
165-
GO111MODULE=$(GO111MODULE) $(GO) mod tidy
166-
ifneq (,$(wildcard vendor))
167-
GO111MODULE=$(GO111MODULE) $(GO) mod vendor
168-
endif
138+
$(GO) mod tidy
169139

170140
.PHONY: common-test-short
171141
common-test-short: $(GOTEST_DIR)
172142
@echo ">> running short tests"
173-
GO111MODULE=$(GO111MODULE) $(GOTEST) -short $(GOOPTS) $(pkgs)
143+
$(GOTEST) -short $(GOOPTS) $(pkgs)
174144

175145
.PHONY: common-test
176146
common-test: $(GOTEST_DIR)
177147
@echo ">> running all tests"
178-
GO111MODULE=$(GO111MODULE) $(GOTEST) $(test-flags) $(GOOPTS) $(pkgs)
148+
$(GOTEST) $(test-flags) $(GOOPTS) $(pkgs)
179149

180150
$(GOTEST_DIR):
181151
@mkdir -p $@
182152

183153
.PHONY: common-format
184154
common-format:
185155
@echo ">> formatting code"
186-
GO111MODULE=$(GO111MODULE) $(GO) fmt $(pkgs)
156+
$(GO) fmt $(pkgs)
187157

188158
.PHONY: common-vet
189159
common-vet:
190160
@echo ">> vetting code"
191-
GO111MODULE=$(GO111MODULE) $(GO) vet $(GOOPTS) $(pkgs)
161+
$(GO) vet $(GOOPTS) $(pkgs)
192162

193163
.PHONY: common-lint
194164
common-lint: $(GOLANGCI_LINT)
195165
ifdef GOLANGCI_LINT
196166
@echo ">> running golangci-lint"
197-
ifdef GO111MODULE
198167
# 'go list' needs to be executed before staticcheck to prepopulate the modules cache.
199168
# Otherwise staticcheck might fail randomly for some reason not yet explained.
200-
GO111MODULE=$(GO111MODULE) $(GO) list -e -compiled -test=true -export=false -deps=true -find=false -tags= -- ./... > /dev/null
201-
GO111MODULE=$(GO111MODULE) $(GOLANGCI_LINT) run $(GOLANGCI_LINT_OPTS) $(pkgs)
202-
else
203-
$(GOLANGCI_LINT) run $(pkgs)
204-
endif
169+
$(GO) list -e -compiled -test=true -export=false -deps=true -find=false -tags= -- ./... > /dev/null
170+
$(GOLANGCI_LINT) run $(GOLANGCI_LINT_OPTS) $(pkgs)
205171
endif
206172

207173
.PHONY: common-yamllint
@@ -218,28 +184,15 @@ endif
218184
common-staticcheck: lint
219185

220186
.PHONY: common-unused
221-
common-unused: $(GOVENDOR)
222-
ifdef GOVENDOR
223-
@echo ">> running check for unused packages"
224-
@$(GOVENDOR) list +unused | grep . && exit 1 || echo 'No unused packages'
225-
else
226-
ifdef GO111MODULE
187+
common-unused:
227188
@echo ">> running check for unused/missing packages in go.mod"
228-
GO111MODULE=$(GO111MODULE) $(GO) mod tidy
229-
ifeq (,$(wildcard vendor))
189+
$(GO) mod tidy
230190
@git diff --exit-code -- go.sum go.mod
231-
else
232-
@echo ">> running check for unused packages in vendor/"
233-
GO111MODULE=$(GO111MODULE) $(GO) mod vendor
234-
@git diff --exit-code -- go.sum go.mod vendor/
235-
endif
236-
endif
237-
endif
238191

239192
.PHONY: common-build
240193
common-build: promu
241194
@echo ">> building binaries"
242-
GO111MODULE=$(GO111MODULE) $(PROMU) build --prefix $(PREFIX) $(PROMU_BINARIES)
195+
$(PROMU) build --prefix $(PREFIX) $(PROMU_BINARIES)
243196

244197
.PHONY: common-tarball
245198
common-tarball: promu
@@ -295,12 +248,6 @@ $(GOLANGCI_LINT):
295248
| sh -s -- -b $(FIRST_GOPATH)/bin $(GOLANGCI_LINT_VERSION)
296249
endif
297250

298-
ifdef GOVENDOR
299-
.PHONY: $(GOVENDOR)
300-
$(GOVENDOR):
301-
GOOS= GOARCH= $(GO) get -u github.com/kardianos/govendor
302-
endif
303-
304251
.PHONY: precheck
305252
precheck::
306253

README.md

+35-10
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
[![CircleCI](https://circleci.com/gh/prometheus-community/elasticsearch_exporter.svg?style=svg)](https://circleci.com/gh/prometheus-community/elasticsearch_exporter)
33
[![Go Report Card](https://goreportcard.com/badge/github.com/prometheus-community/elasticsearch_exporter)](https://goreportcard.com/report/github.com/prometheus-community/elasticsearch_exporter)
44

5-
Prometheus exporter for various metrics about ElasticSearch, written in Go.
5+
Prometheus exporter for various metrics about Elasticsearch, written in Go.
66

77
### Installation
88

@@ -30,11 +30,16 @@ elasticsearch_exporter:
3030
3131
#### Kubernetes
3232
33-
You can find a helm chart in the stable charts repository at https://github.com/kubernetes/charts/tree/master/stable/elasticsearch-exporter.
33+
You can find a helm chart in the prometheus-community charts repository at https://github.com/prometheus-community/helm-charts/tree/main/charts/prometheus-elasticsearch-exporter
34+
35+
```bash
36+
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
37+
helm install [RELEASE_NAME] prometheus-community/prometheus-elasticsearch-exporter
38+
```
3439

3540
### Configuration
3641

37-
**NOTE:** The exporter fetches information from an ElasticSearch cluster on every scrape, therefore having a too short scrape interval can impose load on ES master nodes, particularly if you run with `--es.all` and `--es.indices`. We suggest you measure how long fetching `/_nodes/stats` and `/_all/_stats` takes for your ES cluster to determine whether your scraping interval is too short. As a last resort, you can scrape this exporter using a dedicated job with its own scraping interval.
42+
**NOTE:** The exporter fetches information from an Elasticsearch cluster on every scrape, therefore having a too short scrape interval can impose load on ES master nodes, particularly if you run with `--es.all` and `--es.indices`. We suggest you measure how long fetching `/_nodes/stats` and `/_all/_stats` takes for your ES cluster to determine whether your scraping interval is too short. As a last resort, you can scrape this exporter using a dedicated job with its own scraping interval.
3843

3944
Below is the command line options summary:
4045
```bash
@@ -49,22 +54,24 @@ elasticsearch_exporter --help
4954
| es.indices | 1.0.2 | If true, query stats for all indices in the cluster. | false |
5055
| es.indices_settings | 1.0.4rc1 | If true, query settings stats for all indices in the cluster. | false |
5156
| es.indices_mappings | 1.2.0 | If true, query stats for mappings of all indices of the cluster. | false |
57+
| es.aliases | 1.0.4rc1 | If true, include informational aliases metrics. | true |
5258
| es.shards | 1.0.3rc1 | If true, query stats for all indices in the cluster, including shard-level stats (implies `es.indices=true`). | false |
5359
| es.snapshots | 1.0.4rc1 | If true, query stats for the cluster snapshots. | false |
60+
| es.slm | | If true, query stats for SLM. | false |
5461
| es.timeout | 1.0.2 | Timeout for trying to get stats from Elasticsearch. (ex: 20s) | 5s |
5562
| es.ca | 1.0.2 | Path to PEM file that contains trusted Certificate Authorities for the Elasticsearch connection. | |
5663
| es.client-private-key | 1.0.2 | Path to PEM file that contains the private key for client auth when connecting to Elasticsearch. | |
5764
| es.client-cert | 1.0.2 | Path to PEM file that contains the corresponding cert for the private key to connect to Elasticsearch. | |
5865
| es.clusterinfo.interval | 1.1.0rc1 | Cluster info update interval for the cluster label | 5m |
5966
| es.ssl-skip-verify | 1.0.4rc1 | Skip SSL verification when connecting to Elasticsearch. | false |
60-
| es.apiKey | unreleased | API Key to use for authenticating against Elasticsearch. | |
6167
| web.listen-address | 1.0.2 | Address to listen on for web interface and telemetry. | :9114 |
6268
| web.telemetry-path | 1.0.2 | Path under which to expose metrics. | /metrics |
6369
| version | 1.0.2 | Show version info on stdout and exit. | |
6470

6571
Commandline parameters start with a single `-` for versions less than `1.1.0rc1`.
66-
For versions greater than `1.1.0rc1`, commandline parameters are specified with `--`. Also, all commandline parameters can be provided as environment variables. The environment variable name is derived from the parameter name
67-
by replacing `.` and `-` with `_` and upper-casing the parameter name.
72+
For versions greater than `1.1.0rc1`, commandline parameters are specified with `--`.
73+
74+
The API key used to connect can be set with the `ES_API_KEY` environment variable.
6875

6976
#### Elasticsearch 7.x security privileges
7077

@@ -81,6 +88,7 @@ es.indices | `indices` `monitor` (per index or `*`) | All actions that are requi
8188
es.indices_settings | `indices` `monitor` (per index or `*`) |
8289
es.shards | not sure if `indices` or `cluster` `monitor` or both |
8390
es.snapshots | `cluster:admin/snapshot/status` and `cluster:admin/repository/get` | [ES Forum Post](https://discuss.elastic.co/t/permissions-for-backup-user-with-x-pack/88057)
91+
es.slm | `read_slm`
8492

8593
Further Information
8694
- [Build in Users](https://www.elastic.co/guide/en/elastic-stack-overview/7.3/built-in-users.html)
@@ -139,8 +147,8 @@ Further Information
139147
| elasticsearch_indices_indexing_index_total | counter | 1 | Total index calls
140148
| elasticsearch_indices_mappings_stats_fields | gauge | 1 | Count of fields currently mapped by index
141149
| elasticsearch_indices_mappings_stats_json_parse_failures_total | counter | 0 | Number of errors while parsing JSON
142-
| elasticsearch_indices_mappings_stats_scrapes_total | counter | 0 | Current total ElasticSearch Indices Mappings scrapes
143-
| elasticsearch_indices_mappings_stats_up | gauge | 0 | Was the last scrape of the ElasticSearch Indices Mappings endpoint successful
150+
| elasticsearch_indices_mappings_stats_scrapes_total | counter | 0 | Current total Elasticsearch Indices Mappings scrapes
151+
| elasticsearch_indices_mappings_stats_up | gauge | 0 | Was the last scrape of the Elasticsearch Indices Mappings endpoint successful
144152
| elasticsearch_indices_merges_docs_total | counter | 1 | Cumulative docs merged
145153
| elasticsearch_indices_merges_total | counter | 1 | Total merges
146154
| elasticsearch_indices_merges_total_size_bytes_total | counter | 1 | Total merge size in bytes
@@ -188,7 +196,7 @@ Further Information
188196
| elasticsearch_os_load5 | gauge | 1 | Midterm load average
189197
| elasticsearch_os_load15 | gauge | 1 | Longterm load average
190198
| elasticsearch_process_cpu_percent | gauge | 1 | Percent CPU used by process
191-
| elasticsearch_process_cpu_time_seconds_sum | counter | 3 | Process CPU time in seconds
199+
| elasticsearch_process_cpu_seconds_total | counter | 1 | Process CPU time in seconds
192200
| elasticsearch_process_mem_resident_size_bytes | gauge | 1 | Resident memory in use by process in bytes
193201
| elasticsearch_process_mem_share_size_bytes | gauge | 1 | Shared memory in use by process in bytes
194202
| elasticsearch_process_mem_virtual_size_bytes | gauge | 1 | Total virtual memory used in bytes
@@ -216,12 +224,29 @@ Further Information
216224
| elasticsearch_clusterinfo_last_retrieval_success_ts | gauge | 1 | Timestamp of the last successful cluster info retrieval
217225
| elasticsearch_clusterinfo_up | gauge | 1 | Up metric for the cluster info collector
218226
| elasticsearch_clusterinfo_version_info | gauge | 6 | Constant metric with ES version information as labels
227+
| elasticsearch_slm_stats_up | gauge | 0 | Up metric for SLM collector
228+
| elasticsearch_slm_stats_total_scrapes | counter | 0 | Number of scrapes for SLM collector
229+
| elasticsearch_slm_stats_json_parse_failures | counter | 0 | JSON parse failures for SLM collector
230+
| elasticsearch_slm_stats_retention_runs_total | counter | 0 | Total retention runs
231+
| elasticsearch_slm_stats_retention_failed_total | counter | 0 | Total failed retention runs
232+
| elasticsearch_slm_stats_retention_timed_out_total | counter | 0 | Total retention run timeouts
233+
| elasticsearch_slm_stats_retention_deletion_time_seconds | gauge | 0 | Retention run deletion time
234+
| elasticsearch_slm_stats_total_snapshots_taken_total | counter | 0 | Total snapshots taken
235+
| elasticsearch_slm_stats_total_snapshots_failed_total | counter | 0 | Total snapshots failed
236+
| elasticsearch_slm_stats_total_snapshots_deleted_total | counter | 0 | Total snapshots deleted
237+
| elasticsearch_slm_stats_total_snapshots_failed_total | counter | 0 | Total snapshots failed
238+
| elasticsearch_slm_stats_snapshots_taken_total | counter | 1 | Snapshots taken by policy
239+
| elasticsearch_slm_stats_snapshots_failed_total | counter | 1 | Snapshots failed by policy
240+
| elasticsearch_slm_stats_snapshots_deleted_total | counter | 1 | Snapshots deleted by policy
241+
| elasticsearch_slm_stats_snapshot_deletion_failures_total | counter | 1 | Snapshot deletion failures by policy
242+
| elasticsearch_slm_stats_operation_mode | gauge | 1 | SLM operation mode (Running, stopping, stopped)
243+
219244

220245
### Alerts & Recording Rules
221246

222247
We provide examples for [Prometheus](http://prometheus.io) [alerts and recording rules](examples/prometheus/elasticsearch.rules) as well as an [Grafana](http://www.grafana.org) [Dashboard](examples/grafana/dashboard.json) and a [Kubernetes](http://kubernetes.io) [Deployment](examples/kubernetes/deployment.yml).
223248

224-
The example dashboard needs the [node_exporter](https://github.com/prometheus/node_exporter) installed. In order to select the nodes that belong to the ElasticSearch cluster, we rely on a label `cluster`.
249+
The example dashboard needs the [node_exporter](https://github.com/prometheus/node_exporter) installed. In order to select the nodes that belong to the Elasticsearch cluster, we rely on a label `cluster`.
225250
Depending on your setup, it can derived from the platform metadata:
226251

227252
For example on [GCE](https://cloud.google.com)

0 commit comments

Comments
 (0)