Skip to content

Commit

Permalink
Document api_key in apm-server.yml file (#3138) (#3173)
Browse files Browse the repository at this point in the history
related to #3137
  • Loading branch information
simitt authored Jan 15, 2020
1 parent edb7683 commit 421d1b7
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 15 deletions.
19 changes: 14 additions & 5 deletions _meta/beat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,11 @@ apm-server:
# IPv6 addresses should always be defined as: `https://[2001:db8::1]:9200`.
# hosts: ["localhost:9200"]

# Optional protocol and basic auth credentials.
# Protocol - either `http` (default) or `https`.
#protocol: "https"

# Authentication credentials - either API key or username/password.
#api_key: "id:api_key"
#username: "elastic"
#password: "changeme"

Expand Down Expand Up @@ -513,8 +516,11 @@ output.elasticsearch:
# Set gzip compression level.
#compression_level: 0

# Optional protocol and basic auth credentials.
# Protocol - either `http` (default) or `https`.
#protocol: "https"

# Authentication credentials - either API key or username/password.
#api_key: "id:api_key"
#username: "elastic"
#password: "changeme"

Expand Down Expand Up @@ -1014,10 +1020,13 @@ output.elasticsearch:
# you can simply uncomment the following line.
#monitoring.elasticsearch:

# Optional protocol and basic auth credentials.
# Protocol - either `http` (default) or `https`.
#protocol: "https"
#username: "apm_system"
#password: ""

# Authentication credentials - either API key or username/password.
#api_key: "id:api_key"
#username: "elastic"
#password: "changeme"

# Array of hosts to connect to.
# Scheme and port can be left out and will be set to the default (`http` and `9200`).
Expand Down
19 changes: 14 additions & 5 deletions apm-server.docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,11 @@ apm-server:
# IPv6 addresses should always be defined as: `https://[2001:db8::1]:9200`.
# hosts: ["localhost:9200"]

# Optional protocol and basic auth credentials.
# Protocol - either `http` (default) or `https`.
#protocol: "https"

# Authentication credentials - either API key or username/password.
#api_key: "id:api_key"
#username: "elastic"
#password: "changeme"

Expand Down Expand Up @@ -513,8 +516,11 @@ output.elasticsearch:
# Set gzip compression level.
#compression_level: 0

# Optional protocol and basic auth credentials.
# Protocol - either `http` (default) or `https`.
#protocol: "https"

# Authentication credentials - either API key or username/password.
#api_key: "id:api_key"
#username: "elastic"
#password: "changeme"

Expand Down Expand Up @@ -1014,10 +1020,13 @@ output.elasticsearch:
# you can simply uncomment the following line.
#monitoring.elasticsearch:

# Optional protocol and basic auth credentials.
# Protocol - either `http` (default) or `https`.
#protocol: "https"
#username: "apm_system"
#password: ""

# Authentication credentials - either API key or username/password.
#api_key: "id:api_key"
#username: "elastic"
#password: "changeme"

# Array of hosts to connect to.
# Scheme and port can be left out and will be set to the default (`http` and `9200`).
Expand Down
19 changes: 14 additions & 5 deletions apm-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,11 @@ apm-server:
# IPv6 addresses should always be defined as: `https://[2001:db8::1]:9200`.
# hosts: ["localhost:9200"]

# Optional protocol and basic auth credentials.
# Protocol - either `http` (default) or `https`.
#protocol: "https"

# Authentication credentials - either API key or username/password.
#api_key: "id:api_key"
#username: "elastic"
#password: "changeme"

Expand Down Expand Up @@ -513,8 +516,11 @@ output.elasticsearch:
# Set gzip compression level.
#compression_level: 0

# Optional protocol and basic auth credentials.
# Protocol - either `http` (default) or `https`.
#protocol: "https"

# Authentication credentials - either API key or username/password.
#api_key: "id:api_key"
#username: "elastic"
#password: "changeme"

Expand Down Expand Up @@ -1014,10 +1020,13 @@ output.elasticsearch:
# you can simply uncomment the following line.
#monitoring.elasticsearch:

# Optional protocol and basic auth credentials.
# Protocol - either `http` (default) or `https`.
#protocol: "https"
#username: "apm_system"
#password: ""

# Authentication credentials - either API key or username/password.
#api_key: "id:api_key"
#username: "elastic"
#password: "changeme"

# Array of hosts to connect to.
# Scheme and port can be left out and will be set to the default (`http` and `9200`).
Expand Down
4 changes: 4 additions & 0 deletions elasticsearch/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package elasticsearch

import (
"context"
"encoding/base64"
"encoding/json"
"errors"
"io"
Expand Down Expand Up @@ -92,6 +93,9 @@ func NewClient(config *Config) (Client, error) {

// NewVersionedClient returns the right elasticsearch client for the current Stack version, as an interface
func NewVersionedClient(apikey, user, pwd string, addresses []string, transport http.RoundTripper) (Client, error) {
if apikey != "" {
apikey = base64.StdEncoding.EncodeToString([]byte(apikey))
}
version := common.MustNewVersion(version.GetDefaultVersion())
if version.IsMajor(8) {
c, err := newV8Client(apikey, user, pwd, addresses, transport)
Expand Down

0 comments on commit 421d1b7

Please sign in to comment.