Skip to content

Commit 75c4d26

Browse files
author
Шабакаев Илья Исмаилович
committed
2 parents 73d23aa + 416fa22 commit 75c4d26

31 files changed

+2125
-135
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ executors:
66
# This must match .promu.yml.
77
golang:
88
docker:
9-
- image: cimg/go:1.18
9+
- image: cimg/go:1.19
1010
jobs:
1111
test:
1212
executor: golang

.promu.yml

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

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
## 1.5.0 / 2022-07-28
2+
3+
* [FEATURE] Add metrics collection for data stream statistics #592
4+
* [FEATURE] Support for AWS Elasticsearch using AWS SDK v2 #597
5+
* [BUGFIX] Fix cluster settings collection when max_shards_per_node is manually set. #603
6+
7+
## 1.4.0 / 2022-06-29
8+
9+
* [BREAKING] Remove ENV var support for most non-sensitive options. #518
10+
* [BREAKING] Rename elasticsearch_process_cpu_time_seconds_sum to elasticsearch_process_cpu_seconds_total #520
11+
* [FEATURE] Add metric for index aliases #563
12+
* [FEATURE] Add metric for number of shards on a node #535
13+
* [FEATURE] Add metrics for SLM (snapshot lifecycle management) #558
14+
* [FEATURE] Add metric for JVM uptime #537
15+
* [FEATURE] Add metrics for current searches and current indexing documents #485
16+
* [BUGFIX] Remove the elasticsearch_process_cpu_time_seconds_sum metric as it was never used #498
17+
118
## 1.3.0 / 2021-10-21
219

320
* [FEATURE] Add support for passing elasticsearch credentials via the ES_USERNAME and ES_PASSWORD environment varialbes #461

Makefile.common

Lines changed: 16 additions & 66 deletions
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

@@ -81,16 +58,19 @@ endif
8158
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

61+
SKIP_GOLANGCI_LINT :=
8462
GOLANGCI_LINT :=
8563
GOLANGCI_LINT_OPTS ?=
86-
GOLANGCI_LINT_VERSION ?= v1.45.2
64+
GOLANGCI_LINT_VERSION ?= v1.49.0
8765
# golangci-lint only supports linux, darwin and windows platforms on i386/amd64.
8866
# windows isn't included here because of the path separator being different.
8967
ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux darwin))
9068
ifeq ($(GOHOSTARCH),$(filter $(GOHOSTARCH),amd64 i386))
9169
# If we're in CI and there is an Actions file, that means the linter
9270
# is being run in Actions, so we don't need to run it here.
93-
ifeq (,$(CIRCLE_JOB))
71+
ifneq (,$(SKIP_GOLANGCI_LINT))
72+
GOLANGCI_LINT :=
73+
else ifeq (,$(CIRCLE_JOB))
9474
GOLANGCI_LINT := $(FIRST_GOPATH)/bin/golangci-lint
9575
else ifeq (,$(wildcard .github/workflows/golangci-lint.yml))
9676
GOLANGCI_LINT := $(FIRST_GOPATH)/bin/golangci-lint
@@ -150,58 +130,47 @@ common-check_license:
150130
.PHONY: common-deps
151131
common-deps:
152132
@echo ">> getting dependencies"
153-
ifdef GO111MODULE
154-
GO111MODULE=$(GO111MODULE) $(GO) mod download
155-
else
156-
$(GO) get $(GOOPTS) -t ./...
157-
endif
133+
$(GO) mod download
158134

159135
.PHONY: update-go-deps
160136
update-go-deps:
161137
@echo ">> updating Go dependencies"
162138
@for m in $$($(GO) list -mod=readonly -m -f '{{ if and (not .Indirect) (not .Main)}}{{.Path}}{{end}}' all); do \
163139
$(GO) get -d $$m; \
164140
done
165-
GO111MODULE=$(GO111MODULE) $(GO) mod tidy
166-
ifneq (,$(wildcard vendor))
167-
GO111MODULE=$(GO111MODULE) $(GO) mod vendor
168-
endif
141+
$(GO) mod tidy
169142

170143
.PHONY: common-test-short
171144
common-test-short: $(GOTEST_DIR)
172145
@echo ">> running short tests"
173-
GO111MODULE=$(GO111MODULE) $(GOTEST) -short $(GOOPTS) $(pkgs)
146+
$(GOTEST) -short $(GOOPTS) $(pkgs)
174147

175148
.PHONY: common-test
176149
common-test: $(GOTEST_DIR)
177150
@echo ">> running all tests"
178-
GO111MODULE=$(GO111MODULE) $(GOTEST) $(test-flags) $(GOOPTS) $(pkgs)
151+
$(GOTEST) $(test-flags) $(GOOPTS) $(pkgs)
179152

180153
$(GOTEST_DIR):
181154
@mkdir -p $@
182155

183156
.PHONY: common-format
184157
common-format:
185158
@echo ">> formatting code"
186-
GO111MODULE=$(GO111MODULE) $(GO) fmt $(pkgs)
159+
$(GO) fmt $(pkgs)
187160

188161
.PHONY: common-vet
189162
common-vet:
190163
@echo ">> vetting code"
191-
GO111MODULE=$(GO111MODULE) $(GO) vet $(GOOPTS) $(pkgs)
164+
$(GO) vet $(GOOPTS) $(pkgs)
192165

193166
.PHONY: common-lint
194167
common-lint: $(GOLANGCI_LINT)
195168
ifdef GOLANGCI_LINT
196169
@echo ">> running golangci-lint"
197-
ifdef GO111MODULE
198170
# 'go list' needs to be executed before staticcheck to prepopulate the modules cache.
199171
# 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
172+
$(GO) list -e -compiled -test=true -export=false -deps=true -find=false -tags= -- ./... > /dev/null
173+
$(GOLANGCI_LINT) run $(GOLANGCI_LINT_OPTS) $(pkgs)
205174
endif
206175

207176
.PHONY: common-yamllint
@@ -218,28 +187,15 @@ endif
218187
common-staticcheck: lint
219188

220189
.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
190+
common-unused:
227191
@echo ">> running check for unused/missing packages in go.mod"
228-
GO111MODULE=$(GO111MODULE) $(GO) mod tidy
229-
ifeq (,$(wildcard vendor))
192+
$(GO) mod tidy
230193
@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
238194

239195
.PHONY: common-build
240196
common-build: promu
241197
@echo ">> building binaries"
242-
GO111MODULE=$(GO111MODULE) $(PROMU) build --prefix $(PREFIX) $(PROMU_BINARIES)
198+
$(PROMU) build --prefix $(PREFIX) $(PROMU_BINARIES)
243199

244200
.PHONY: common-tarball
245201
common-tarball: promu
@@ -295,12 +251,6 @@ $(GOLANGCI_LINT):
295251
| sh -s -- -b $(FIRST_GOPATH)/bin $(GOLANGCI_LINT_VERSION)
296252
endif
297253

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

README.md

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# Elasticsearch Exporter
2+
23
[![CircleCI](https://circleci.com/gh/prometheus-community/elasticsearch_exporter.svg?style=svg)](https://circleci.com/gh/prometheus-community/elasticsearch_exporter)
34
[![Go Report Card](https://goreportcard.com/badge/github.com/prometheus-community/elasticsearch_exporter)](https://goreportcard.com/report/github.com/prometheus-community/elasticsearch_exporter)
45

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

78
### Installation
89

910
For pre-built binaries please take a look at the releases.
10-
https://github.com/prometheus-community/elasticsearch_exporter/releases
11+
<https://github.com/prometheus-community/elasticsearch_exporter/releases>
1112

1213
#### Docker
1314

@@ -30,7 +31,7 @@ elasticsearch_exporter:
3031
3132
#### Kubernetes
3233
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+
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>
3435
3536
```bash
3637
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
@@ -39,16 +40,17 @@ helm install [RELEASE_NAME] prometheus-community/prometheus-elasticsearch-export
3940

4041
### Configuration
4142

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.
43+
**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.
4344

4445
Below is the command line options summary:
46+
4547
```bash
4648
elasticsearch_exporter --help
4749
```
4850

4951
| Argument | Introduced in Version | Description | Default |
5052
| -------- | --------------------- | ----------- | ----------- |
51-
| es.uri | 1.0.2 | Address (host and port) of the Elasticsearch node we should connect to. This could be a local node (`localhost:9200`, for instance), or the address of a remote Elasticsearch server. When basic auth is needed, specify as: `<proto>://<user>:<password>@<host>:<port>`. E.G., `http://admin:pass@localhost:9200`. Special characters in the user credentials need to be URL-encoded. | http://localhost:9200 |
53+
| es.uri | 1.0.2 | Address (host and port) of the Elasticsearch node we should connect to. This could be a local node (`localhost:9200`, for instance), or the address of a remote Elasticsearch server. When basic auth is needed, specify as: `<proto>://<user>:<password>@<host>:<port>`. E.G., `http://admin:pass@localhost:9200`. Special characters in the user credentials need to be URL-encoded. | <http://localhost:9200> |
5254
| es.all | 1.0.2 | If true, query stats for all nodes in the cluster, rather than just the node we connect to. | false |
5355
| es.cluster_settings | 1.1.0rc1 | If true, query stats for cluster settings. | false |
5456
| es.indices | 1.0.2 | If true, query stats for all indices in the cluster. | false |
@@ -58,6 +60,7 @@ elasticsearch_exporter --help
5860
| es.shards | 1.0.3rc1 | If true, query stats for all indices in the cluster, including shard-level stats (implies `es.indices=true`). | false |
5961
| es.snapshots | 1.0.4rc1 | If true, query stats for the cluster snapshots. | false |
6062
| es.slm | | If true, query stats for SLM. | false |
63+
| es.data_stream | | If true, query state for Data Steams. | false |
6164
| es.timeout | 1.0.2 | Timeout for trying to get stats from Elasticsearch. (ex: 20s) | 5s |
6265
| es.ca | 1.0.2 | Path to PEM file that contains trusted Certificate Authorities for the Elasticsearch connection. | |
6366
| es.client-private-key | 1.0.2 | Path to PEM file that contains the private key for client auth when connecting to Elasticsearch. | |
@@ -66,6 +69,7 @@ elasticsearch_exporter --help
6669
| es.ssl-skip-verify | 1.0.4rc1 | Skip SSL verification when connecting to Elasticsearch. | false |
6770
| web.listen-address | 1.0.2 | Address to listen on for web interface and telemetry. | :9114 |
6871
| web.telemetry-path | 1.0.2 | Path under which to expose metrics. | /metrics |
72+
| aws.region | 1.5.0 | Region for AWS elasticsearch | |
6973
| version | 1.0.2 | Show version info on stdout and exit. | |
7074

7175
Commandline parameters start with a single `-` for versions less than `1.1.0rc1`.
@@ -89,9 +93,11 @@ es.indices_settings | `indices` `monitor` (per index or `*`) |
8993
es.shards | not sure if `indices` or `cluster` `monitor` or both |
9094
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)
9195
es.slm | `read_slm`
96+
es.data_stream | `monitor` or `manage` (per index or `*`) |
9297

9398
Further Information
94-
- [Build in Users](https://www.elastic.co/guide/en/elastic-stack-overview/7.3/built-in-users.html)
99+
100+
- [Built in Users](https://www.elastic.co/guide/en/elastic-stack-overview/7.3/built-in-users.html)
95101
- [Defining Roles](https://www.elastic.co/guide/en/elastic-stack-overview/7.3/defining-roles.html)
96102
- [Privileges](https://www.elastic.co/guide/en/elastic-stack-overview/7.3/security-privileges.html)
97103

@@ -147,8 +153,8 @@ Further Information
147153
| elasticsearch_indices_indexing_index_total | counter | 1 | Total index calls
148154
| elasticsearch_indices_mappings_stats_fields | gauge | 1 | Count of fields currently mapped by index
149155
| elasticsearch_indices_mappings_stats_json_parse_failures_total | counter | 0 | Number of errors while parsing JSON
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
156+
| elasticsearch_indices_mappings_stats_scrapes_total | counter | 0 | Current total Elasticsearch Indices Mappings scrapes
157+
| elasticsearch_indices_mappings_stats_up | gauge | 0 | Was the last scrape of the Elasticsearch Indices Mappings endpoint successful
152158
| elasticsearch_indices_merges_docs_total | counter | 1 | Cumulative docs merged
153159
| elasticsearch_indices_merges_total | counter | 1 | Total merges
154160
| elasticsearch_indices_merges_total_size_bytes_total | counter | 1 | Total merge size in bytes
@@ -172,6 +178,7 @@ Further Information
172178
| elasticsearch_indices_segments_memory_bytes | gauge | 1 | Current memory size of segments in bytes
173179
| elasticsearch_indices_settings_stats_read_only_indices | gauge | 1 | Count of indices that have read_only_allow_delete=true
174180
| elasticsearch_indices_settings_total_fields | gauge | | Index setting value for index.mapping.total_fields.limit (total allowable mapped fields in a index)
181+
| elasticsearch_indices_settings_replicas | gauge | | Index setting value for index.replicas
175182
| elasticsearch_indices_shards_docs | gauge | 3 | Count of documents on this shard
176183
| elasticsearch_indices_shards_docs_deleted | gauge | 3 | Count of deleted documents on each shard
177184
| elasticsearch_indices_store_size_bytes | gauge | 1 | Current size of stored index data in bytes
@@ -240,13 +247,17 @@ Further Information
240247
| elasticsearch_slm_stats_snapshots_deleted_total | counter | 1 | Snapshots deleted by policy
241248
| elasticsearch_slm_stats_snapshot_deletion_failures_total | counter | 1 | Snapshot deletion failures by policy
242249
| elasticsearch_slm_stats_operation_mode | gauge | 1 | SLM operation mode (Running, stopping, stopped)
243-
250+
| elasticsearch_data_stream_stats_up | gauge | 0 | Up metric for Data Stream collection
251+
| elasticsearch_data_stream_stats_total_scrapes | counter | 0 | Total scrapes for Data Stream stats
252+
| elasticsearch_data_stream_stats_json_parse_failures | counter | 0 | Number of parsing failures for Data Stream stats
253+
| elasticsearch_data_stream_backing_indices_total | gauge | 1 | Number of backing indices for Data Stream
254+
| elasticsearch_data_stream_store_size_bytes | gauge | 1 | Current size of data stream backing indices in bytes
244255

245256
### Alerts & Recording Rules
246257

247258
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).
248259

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`.
260+
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`.
250261
Depending on your setup, it can derived from the platform metadata:
251262

252263
For example on [GCE](https://cloud.google.com)
@@ -274,7 +285,7 @@ who transferred this repository to us in January 2017.
274285

275286
Maintainers of this repository:
276287

277-
* Christoph Oelmüller <[email protected]> @zwopir
288+
- Christoph Oelmüller <[email protected]> @zwopir
278289

279290
Please refer to the Git commit log for a complete list of contributors.
280291

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.3.0
1+
1.5.0

collector/cluster_health.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ func NewClusterHealth(logger log.Logger, client *http.Client, url *url.URL) *Clu
6868

6969
up: prometheus.NewGauge(prometheus.GaugeOpts{
7070
Name: prometheus.BuildFQName(namespace, subsystem, "up"),
71-
Help: "Was the last scrape of the ElasticSearch cluster health endpoint successful.",
71+
Help: "Was the last scrape of the Elasticsearch cluster health endpoint successful.",
7272
}),
7373
totalScrapes: prometheus.NewCounter(prometheus.CounterOpts{
7474
Name: prometheus.BuildFQName(namespace, subsystem, "total_scrapes"),
75-
Help: "Current total ElasticSearch cluster health scrapes.",
75+
Help: "Current total Elasticsearch cluster health scrapes.",
7676
}),
7777
jsonParseFailures: prometheus.NewCounter(prometheus.CounterOpts{
7878
Name: prometheus.BuildFQName(namespace, subsystem, "json_parse_failures"),

collector/cluster_info.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"net/http"
2121
"net/url"
2222

23-
"github.com/blang/semver"
23+
"github.com/blang/semver/v4"
2424
"github.com/go-kit/log"
2525
"github.com/prometheus/client_golang/prometheus"
2626
)

0 commit comments

Comments
 (0)