forked from prometheus-community/elasticsearch_exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into add-aliases
* master: Refactor cluster info collector (prometheus-community#536) Fix linting that was missed in CI run (prometheus-community#568) Grafana dashboard: use new node exporter metric names (prometheus-community#501) publish total shards on a node (prometheus-community#535) Add additional collector for SLM stats (prometheus-community#558) Update common Prometheus files (prometheus-community#565) Update build (prometheus-community#562) Signed-off-by: Steven Cipriano <cipriano@squareup.com>
- Loading branch information
Showing
18 changed files
with
1,044 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "gomod" | ||
directory: "/" | ||
schedule: | ||
interval: "monthly" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
extends: default | ||
|
||
rules: | ||
braces: | ||
max-spaces-inside: 1 | ||
level: error | ||
brackets: | ||
max-spaces-inside: 1 | ||
level: error | ||
commas: disable | ||
comments: disable | ||
comments-indentation: disable | ||
document-start: disable | ||
indentation: | ||
spaces: consistent | ||
indent-sequences: consistent | ||
key-duplicates: | ||
ignore: | | ||
config/testdata/section_key_dup.bad.yml | ||
line-length: disable | ||
truthy: | ||
ignore: | | ||
.github/workflows/codeql-analysis.yml | ||
.github/workflows/funcbench.yml | ||
.github/workflows/fuzzing.yml | ||
.github/workflows/prombench.yml | ||
.github/workflows/golangci-lint.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
## Prometheus Community Code of Conduct | ||
# Prometheus Community Code of Conduct | ||
|
||
Prometheus follows the [CNCF Code of Conduct](https://github.com/cncf/foundation/blob/master/code-of-conduct.md). | ||
Prometheus follows the [CNCF Code of Conduct](https://github.com/cncf/foundation/blob/main/code-of-conduct.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
// Copyright 2022 The Prometheus Authors | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package collector | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"io/ioutil" | ||
"net/http" | ||
"net/url" | ||
|
||
"github.com/blang/semver" | ||
"github.com/go-kit/log" | ||
"github.com/prometheus/client_golang/prometheus" | ||
) | ||
|
||
func init() { | ||
registerCollector("cluster-info", defaultEnabled, NewClusterInfo) | ||
} | ||
|
||
type ClusterInfoCollector struct { | ||
logger log.Logger | ||
u *url.URL | ||
hc *http.Client | ||
} | ||
|
||
func NewClusterInfo(logger log.Logger, u *url.URL, hc *http.Client) (Collector, error) { | ||
return &ClusterInfoCollector{ | ||
logger: logger, | ||
u: u, | ||
hc: hc, | ||
}, nil | ||
} | ||
|
||
var clusterInfoDesc = map[string]*prometheus.Desc{ | ||
"version": prometheus.NewDesc( | ||
prometheus.BuildFQName(namespace, "", "version"), | ||
"Elasticsearch version information.", | ||
[]string{ | ||
"cluster", | ||
"cluster_uuid", | ||
"build_date", | ||
"build_hash", | ||
"version", | ||
"lucene_version", | ||
}, | ||
nil, | ||
), | ||
} | ||
|
||
// ClusterInfoResponse is the cluster info retrievable from the / endpoint | ||
type ClusterInfoResponse struct { | ||
Name string `json:"name"` | ||
ClusterName string `json:"cluster_name"` | ||
ClusterUUID string `json:"cluster_uuid"` | ||
Version VersionInfo `json:"version"` | ||
Tagline string `json:"tagline"` | ||
} | ||
|
||
// VersionInfo is the version info retrievable from the / endpoint, embedded in ClusterInfoResponse | ||
type VersionInfo struct { | ||
Number semver.Version `json:"number"` | ||
BuildHash string `json:"build_hash"` | ||
BuildDate string `json:"build_date"` | ||
BuildSnapshot bool `json:"build_snapshot"` | ||
LuceneVersion semver.Version `json:"lucene_version"` | ||
} | ||
|
||
func (c *ClusterInfoCollector) Update(ctx context.Context, ch chan<- prometheus.Metric) error { | ||
resp, err := c.hc.Get(c.u.String()) | ||
if err != nil { | ||
return err | ||
} | ||
defer resp.Body.Close() | ||
b, err := ioutil.ReadAll(resp.Body) | ||
if err != nil { | ||
return err | ||
} | ||
var info ClusterInfoResponse | ||
err = json.Unmarshal(b, &info) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
ch <- prometheus.MustNewConstMetric( | ||
clusterInfoDesc["version"], | ||
prometheus.GaugeValue, | ||
1, | ||
info.ClusterName, | ||
info.ClusterUUID, | ||
info.Version.BuildDate, | ||
info.Version.BuildHash, | ||
info.Version.Number.String(), | ||
info.Version.LuceneVersion.String(), | ||
) | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.