Skip to content

Commit 7d13c0f

Browse files
authored
Merge pull request #8 from sysdiglabs/master
Master
2 parents 118678f + 276106b commit 7d13c0f

26 files changed

+173
-326
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
paths:
13+
- "go.sum"
14+
- "go.mod"
15+
- "**.go"
16+
- "scripts/errcheck_excludes.txt"
17+
- ".github/workflows/golangci-lint.yml"
18+
- ".golangci.yml"
19+
20+
jobs:
21+
golangci:
22+
name: lint
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v2
27+
28+
- name: Lint
29+
uses: golangci/golangci-lint-action@v2
30+
with:
31+
version: v1.42.0

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 1.3.0 / 2021-10-21
2+
3+
* [FEATURE] Add support for passing elasticsearch credentials via the ES_USERNAME and ES_PASSWORD environment varialbes #461
4+
* [FEATURE] Add support for API keys for elasticsearch authentication (Elastic cloud) #459
5+
* [BUGFIX] Fix index stats when shards are unavailable #445
6+
17
## 1.2.1 / 2021-06-29
28

39
* [BUGFIX] Fixed elasticsearch 7.13 node stats metrics #439

Makefile.common

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,18 @@ PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_
8383

8484
GOLANGCI_LINT :=
8585
GOLANGCI_LINT_OPTS ?=
86-
GOLANGCI_LINT_VERSION ?= v1.39.0
86+
GOLANGCI_LINT_VERSION ?= v1.42.0
8787
# golangci-lint only supports linux, darwin and windows platforms on i386/amd64.
8888
# windows isn't included here because of the path separator being different.
8989
ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux darwin))
9090
ifeq ($(GOHOSTARCH),$(filter $(GOHOSTARCH),amd64 i386))
91-
GOLANGCI_LINT := $(FIRST_GOPATH)/bin/golangci-lint
91+
# If we're in CI and there is an Actions file, that means the linter
92+
# is being run in Actions, so we don't need to run it here.
93+
ifeq (,$(CIRCLE_JOB))
94+
GOLANGCI_LINT := $(FIRST_GOPATH)/bin/golangci-lint
95+
else ifeq (,$(wildcard .github/workflows/golangci-lint.yml))
96+
GOLANGCI_LINT := $(FIRST_GOPATH)/bin/golangci-lint
97+
endif
9298
endif
9399
endif
94100

@@ -154,7 +160,7 @@ endif
154160
update-go-deps:
155161
@echo ">> updating Go dependencies"
156162
@for m in $$($(GO) list -mod=readonly -m -f '{{ if and (not .Indirect) (not .Main)}}{{.Path}}{{end}}' all); do \
157-
$(GO) get $$m; \
163+
$(GO) get -d $$m; \
158164
done
159165
GO111MODULE=$(GO111MODULE) $(GO) mod tidy
160166
ifneq (,$(wildcard vendor))

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ elasticsearch_exporter --help
4848
| es.cluster_settings | 1.1.0rc1 | If true, query stats for cluster settings. | false |
4949
| es.indices | 1.0.2 | If true, query stats for all indices in the cluster. | false |
5050
| es.indices_settings | 1.0.4rc1 | If true, query settings stats for all indices in the cluster. | false |
51+
| es.indices_mappings | 1.2.0 | If true, query stats for mappings of all indices of the cluster. | false |
5152
| es.shards | 1.0.3rc1 | If true, query stats for all indices in the cluster, including shard-level stats (implies `es.indices=true`). | false |
5253
| es.snapshots | 1.0.4rc1 | If true, query stats for the cluster snapshots. | false |
5354
| es.timeout | 1.0.2 | Timeout for trying to get stats from Elasticsearch. (ex: 20s) | 5s |
@@ -56,6 +57,7 @@ elasticsearch_exporter --help
5657
| es.client-cert | 1.0.2 | Path to PEM file that contains the corresponding cert for the private key to connect to Elasticsearch. | |
5758
| es.clusterinfo.interval | 1.1.0rc1 | Cluster info update interval for the cluster label | 5m |
5859
| 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. | |
5961
| web.listen-address | 1.0.2 | Address to listen on for web interface and telemetry. | :9114 |
6062
| web.telemetry-path | 1.0.2 | Path under which to expose metrics. | /metrics |
6163
| version | 1.0.2 | Show version info on stdout and exit. | |
@@ -66,6 +68,9 @@ by replacing `.` and `-` with `_` and upper-casing the parameter name.
6668

6769
#### Elasticsearch 7.x security privileges
6870

71+
Username and password can be passed either directly in the URI or through the `ES_USERNAME` and `ES_PASSWORD` environment variables.
72+
Specifying those two environment variables will override authentication passed in the URI (if any).
73+
6974
ES 7.x supports RBACs. The following security privileges are required for the elasticsearch_exporter.
7075

7176
Setting | Privilege Required | Description
@@ -111,6 +116,7 @@ Further Information
111116
| elasticsearch_filesystem_io_stats_device_write_operations_count | gauge | 1 | Count of disk write operations
112117
| elasticsearch_filesystem_io_stats_device_read_size_kilobytes_sum | gauge | 1 | Total kilobytes read from disk
113118
| elasticsearch_filesystem_io_stats_device_write_size_kilobytes_sum | gauge | 1 | Total kilobytes written to disk
119+
| elasticsearch_indices_active_queries | gauge | 1 | The number of currently active queries
114120
| elasticsearch_indices_docs | gauge | 1 | Count of documents on this node
115121
| elasticsearch_indices_docs_deleted | gauge | 1 | Count of deleted documents on this node
116122
| elasticsearch_indices_docs_primary | gauge | | Count of documents with only primary shards on all nodes
@@ -128,6 +134,7 @@ Further Information
128134
| elasticsearch_indices_get_total | counter | 1 | Total get
129135
| elasticsearch_indices_indexing_delete_time_seconds_total | counter | 1 | Total time indexing delete in seconds
130136
| elasticsearch_indices_indexing_delete_total | counter | 1 | Total indexing deletes
137+
| elasticsearch_indices_index_current | gauge | 1 | The number of documents currently being indexed to an index
131138
| elasticsearch_indices_indexing_index_time_seconds_total | counter | 1 | Cumulative index time in seconds
132139
| elasticsearch_indices_indexing_index_total | counter | 1 | Total index calls
133140
| elasticsearch_indices_mappings_stats_fields | gauge | 1 | Count of fields currently mapped by index

VERSION

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

collector/cluster_health.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import (
2121
"net/url"
2222
"path"
2323

24-
"github.com/go-kit/kit/log"
25-
"github.com/go-kit/kit/log/level"
24+
"github.com/go-kit/log"
25+
"github.com/go-kit/log/level"
2626
"github.com/prometheus/client_golang/prometheus"
2727
)
2828

collector/cluster_health_test.go

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

23-
"github.com/go-kit/kit/log"
23+
"github.com/go-kit/log"
2424
)
2525

2626
func TestClusterHealth(t *testing.T) {

collector/cluster_settings.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ import (
2222
"path"
2323
"strconv"
2424

25-
"github.com/go-kit/kit/log"
26-
"github.com/go-kit/kit/log/level"
25+
"github.com/go-kit/log"
26+
"github.com/go-kit/log/level"
2727
"github.com/imdario/mergo"
2828
"github.com/prometheus/client_golang/prometheus"
2929
)

collector/cluster_settings_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"os"
2222
"testing"
2323

24-
"github.com/go-kit/kit/log"
24+
"github.com/go-kit/log"
2525
)
2626

2727
func TestClusterSettingsStats(t *testing.T) {

collector/indices.go

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ import (
2222
"path"
2323
"strconv"
2424

25-
"github.com/go-kit/kit/log"
26-
"github.com/go-kit/kit/log/level"
25+
"github.com/go-kit/log"
26+
"github.com/go-kit/log/level"
2727
"github.com/prometheus-community/elasticsearch_exporter/pkg/clusterinfo"
2828
"github.com/prometheus/client_golang/prometheus"
2929
)
@@ -491,6 +491,18 @@ func NewIndices(logger log.Logger, client *http.Client, url *url.URL, shards boo
491491
},
492492
Labels: indexLabels,
493493
},
494+
{
495+
Type: prometheus.GaugeValue,
496+
Desc: prometheus.NewDesc(
497+
prometheus.BuildFQName(namespace, "search", "active_queries"),
498+
"The number of currently active queries",
499+
indexLabels.keys(), nil,
500+
),
501+
Value: func(indexStats IndexStatsIndexResponse) float64 {
502+
return float64(indexStats.Total.Search.QueryCurrent)
503+
},
504+
Labels: indexLabels,
505+
},
494506
{
495507
Type: prometheus.CounterValue,
496508
Desc: prometheus.NewDesc(
@@ -599,6 +611,18 @@ func NewIndices(logger log.Logger, client *http.Client, url *url.URL, shards boo
599611
},
600612
Labels: indexLabels,
601613
},
614+
{
615+
Type: prometheus.GaugeValue,
616+
Desc: prometheus.NewDesc(
617+
prometheus.BuildFQName(namespace, "index_stats", "index_current"),
618+
"The number of documents currently being indexed to an index",
619+
indexLabels.keys(), nil,
620+
),
621+
Value: func(indexStats IndexStatsIndexResponse) float64 {
622+
return float64(indexStats.Total.Indexing.IndexCurrent)
623+
},
624+
Labels: indexLabels,
625+
},
602626
{
603627
Type: prometheus.CounterValue,
604628
Desc: prometheus.NewDesc(
@@ -1041,7 +1065,9 @@ func (i *Indices) fetchAndDecodeIndexStats() (indexStatsResponse, error) {
10411065
u := *i.url
10421066
u.Path = path.Join(u.Path, "/_all/_stats")
10431067
if i.shards {
1044-
u.RawQuery = "level=shards"
1068+
u.RawQuery = "ignore_unavailable=true&level=shards"
1069+
} else {
1070+
u.RawQuery = "ignore_unavailable=true"
10451071
}
10461072

10471073
res, err := i.client.Get(u.String())

0 commit comments

Comments
 (0)