Skip to content

Commit

Permalink
Add elasticsearch_expoter example
Browse files Browse the repository at this point in the history
Also renamed elasticsearch `uri` config key to `address`.
  • Loading branch information
colega committed Jan 22, 2021
1 parent f5a1df4 commit bfb9e65
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
3 changes: 3 additions & 0 deletions cmd/agent/agent-integrations-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ integrations:
enabled: true
consul_exporter:
enabled: true
elasticsearch_exporter:
enabled: true
address: http://localhost:9200
prometheus_remote_write:
- url: http://localhost:9009/api/prom/push

2 changes: 1 addition & 1 deletion docs/configuration-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -2918,7 +2918,7 @@ Full reference of options:
#
# HTTP API address of an Elasticsearch node.
[ api : <string> | default = "http://localhost:9200" ]
[ address : <string> | default = "http://localhost:9200" ]
# Timeout for trying to get stats from Elasticsearch.
[ timeout: <duration> | default = "5s" ]
Expand Down
15 changes: 15 additions & 0 deletions example/docker-compose/docker-compose.integrations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,18 @@ services:
image: consul
ports:
- "8500:8500"

elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.10.1
environment:
- node.name=elasticsearch
- cluster.name=es-grafana-agent-cluster
- discovery.type=single-node
volumes:
- elasticsearch_data:/usr/share/elasticsearch/data
ports:
- "9200:9200"

volumes:
elasticsearch_data:
driver: local
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
)

var DefaultConfig = Config{
URI: "http://localhost:9200",
Address: "http://localhost:9200",
Timeout: 5 * time.Second,
Node: "_local",
ExportClusterInfoInterval: 5 * time.Minute,
Expand All @@ -33,7 +33,7 @@ type Config struct {
// Exporter configuration

// HTTP API address of an Elasticsearch node.
URI string `yaml:"uri"`
Address string `yaml:"address"`
// Timeout for trying to get stats from Elasticsearch.
Timeout time.Duration `yaml:"timeout"`
// Export stats for all nodes in the cluster. If used, this flag will override the flag es.node.
Expand Down Expand Up @@ -91,12 +91,12 @@ func init() {
// This function replicates the main() function of github.com/justwatchcom/elasticsearch_exporter
// but uses yaml configuration instead of kingpin flags.
func New(logger log.Logger, c *Config) (integrations.Integration, error) {
if c.URI == "" {
return nil, fmt.Errorf("empty uri provided")
if c.Address == "" {
return nil, fmt.Errorf("empty elasticsearch_address provided")
}
esURL, err := url.Parse(c.URI)
esURL, err := url.Parse(c.Address)
if err != nil {
return nil, fmt.Errorf("failed to parse uri: %w", err)
return nil, fmt.Errorf("failed to parse elasticsearch_address: %w", err)
}

// returns nil if not provided and falls back to simple TCP.
Expand Down

0 comments on commit bfb9e65

Please sign in to comment.