Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] Document api_key in apm-server.yml file (#3138) #3173

Merged
merged 1 commit into from
Jan 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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