-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Allow custom port in cloud.id #7887
Conversation
Make it possible for the host section from the cloud.id to contain a port. If the port is not specified, 443 is used, like before. This is proposed fix for elastic#7794.
libbeat/cloudid/cloudid.go
Outdated
kibanaURL := url.URL{Scheme: "https", Host: fmt.Sprintf("%s.%s:443", words[2], words[0])} | ||
// 4. extract port from the host | ||
host := words[0] | ||
port := "443" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Use a constant for the magic number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We make the assumptions that both ES and Kibana will answer on the same port, could it be different?
If this is the case I am OK with the code on our side.
libbeat/cloudid/cloudid.go
Outdated
@@ -31,6 +31,8 @@ import ( | |||
"github.com/elastic/beats/libbeat/logp" | |||
) | |||
|
|||
const DefaultCloudPort = "443" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exported const DefaultCloudPort should have comment or be unexported
libbeat/cloudid/cloudid.go
Outdated
idx := strings.LastIndex(word, ":") | ||
if idx >= 0 { | ||
return word[:idx], word[idx+1:] | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if block ends with a return statement, so drop this else and outdent its block
@ph I made things more flexible to also allow individual ES and KB port. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Make it possible for the cloud.id to contain a custom port. If the port is not specified, 443 is used, like before. The custom port can be specified in multiple ways. The cloudid is formed like this: `<host>:<es-id>:<kb-id>`. The port can be specified either in es-id or kb-id, or in the host section. If specified in both, the more specific one wins (i.e. es-id over host). Examples: ``` 'us-central1.gcp.cloud.es.io:9243$ac31ebb90241773157043c34fd26fd46$a4c06230e48c8fce7be88a074a3bb3e0' ``` Results in: ``` ES: https://ac31ebb90241773157043c34fd26fd46.us-central1.gcp.cloud.es.io:9243 KB: https://a4c06230e48c8fce7be88a074a3bb3e0.us-central1.gcp.cloud.es.io:9243 ``` Or: ``` 'us-central1.gcp.cloud.es.io$ac31ebb90241773157043c34fd26fd46:9243$a4c06230e48c8fce7be88a074a3bb3e0:9244' ``` Results in: ``` ES: https://ac31ebb90241773157043c34fd26fd46.us-central1.gcp.cloud.es.io:9243 KB: https://a4c06230e48c8fce7be88a074a3bb3e0.us-central1.gcp.cloud.es.io:9244 ``` Closes: elastic#7794. (cherry picked from commit daaca33)
Make it possible for the cloud.id to contain a custom port. If the port is not specified, 443 is used, like before. The custom port can be specified in multiple ways. The cloudid is formed like this: `<host>:<es-id>:<kb-id>`. The port can be specified either in es-id or kb-id, or in the host section. If specified in both, the more specific one wins (i.e. es-id over host). Examples: ``` 'us-central1.gcp.cloud.es.io:9243$ac31ebb90241773157043c34fd26fd46$a4c06230e48c8fce7be88a074a3bb3e0' ``` Results in: ``` ES: https://ac31ebb90241773157043c34fd26fd46.us-central1.gcp.cloud.es.io:9243 KB: https://a4c06230e48c8fce7be88a074a3bb3e0.us-central1.gcp.cloud.es.io:9243 ``` Or: ``` 'us-central1.gcp.cloud.es.io$ac31ebb90241773157043c34fd26fd46:9243$a4c06230e48c8fce7be88a074a3bb3e0:9244' ``` Results in: ``` ES: https://ac31ebb90241773157043c34fd26fd46.us-central1.gcp.cloud.es.io:9243 KB: https://a4c06230e48c8fce7be88a074a3bb3e0.us-central1.gcp.cloud.es.io:9244 ``` Closes: elastic#7794. (cherry picked from commit daaca33)
Make it possible for the cloud.id to contain a custom port. If the port is not specified, 443 is used, like before. The custom port can be specified in multiple ways. The cloudid is formed like this: `<host>:<es-id>:<kb-id>`. The port can be specified either in es-id or kb-id, or in the host section. If specified in both, the more specific one wins (i.e. es-id over host). Examples: ``` 'us-central1.gcp.cloud.es.io:9243$ac31ebb90241773157043c34fd26fd46$a4c06230e48c8fce7be88a074a3bb3e0' ``` Results in: ``` ES: https://ac31ebb90241773157043c34fd26fd46.us-central1.gcp.cloud.es.io:9243 KB: https://a4c06230e48c8fce7be88a074a3bb3e0.us-central1.gcp.cloud.es.io:9243 ``` Or: ``` 'us-central1.gcp.cloud.es.io$ac31ebb90241773157043c34fd26fd46:9243$a4c06230e48c8fce7be88a074a3bb3e0:9244' ``` Results in: ``` ES: https://ac31ebb90241773157043c34fd26fd46.us-central1.gcp.cloud.es.io:9243 KB: https://a4c06230e48c8fce7be88a074a3bb3e0.us-central1.gcp.cloud.es.io:9244 ``` Closes: #7794. (cherry picked from commit daaca33)
Make it possible for the cloud.id to contain a custom port. If the port is not specified, 443 is used, like before. The custom port can be specified in multiple ways. The cloudid is formed like this: `<host>:<es-id>:<kb-id>`. The port can be specified either in es-id or kb-id, or in the host section. If specified in both, the more specific one wins (i.e. es-id over host). Examples: ``` 'us-central1.gcp.cloud.es.io:9243$ac31ebb90241773157043c34fd26fd46$a4c06230e48c8fce7be88a074a3bb3e0' ``` Results in: ``` ES: https://ac31ebb90241773157043c34fd26fd46.us-central1.gcp.cloud.es.io:9243 KB: https://a4c06230e48c8fce7be88a074a3bb3e0.us-central1.gcp.cloud.es.io:9243 ``` Or: ``` 'us-central1.gcp.cloud.es.io$ac31ebb90241773157043c34fd26fd46:9243$a4c06230e48c8fce7be88a074a3bb3e0:9244' ``` Results in: ``` ES: https://ac31ebb90241773157043c34fd26fd46.us-central1.gcp.cloud.es.io:9243 KB: https://a4c06230e48c8fce7be88a074a3bb3e0.us-central1.gcp.cloud.es.io:9244 ``` Closes: #7794. (cherry picked from commit daaca33)
Make it possible for the cloud.id to contain a custom port. If the port is not specified, 443 is used, like before. The custom port can be specified in multiple ways. The cloudid is formed like this: `<host>:<es-id>:<kb-id>`. The port can be specified either in es-id or kb-id, or in the host section. If specified in both, the more specific one wins (i.e. es-id over host). Examples: ``` 'us-central1.gcp.cloud.es.io:9243$ac31ebb90241773157043c34fd26fd46$a4c06230e48c8fce7be88a074a3bb3e0' ``` Results in: ``` ES: https://ac31ebb90241773157043c34fd26fd46.us-central1.gcp.cloud.es.io:9243 KB: https://a4c06230e48c8fce7be88a074a3bb3e0.us-central1.gcp.cloud.es.io:9243 ``` Or: ``` 'us-central1.gcp.cloud.es.io$ac31ebb90241773157043c34fd26fd46:9243$a4c06230e48c8fce7be88a074a3bb3e0:9244' ``` Results in: ``` ES: https://ac31ebb90241773157043c34fd26fd46.us-central1.gcp.cloud.es.io:9243 KB: https://a4c06230e48c8fce7be88a074a3bb3e0.us-central1.gcp.cloud.es.io:9244 ``` Closes: elastic#7794. (cherry picked from commit 8d8ac27)
Make it possible for the the cloud.id to contain a custom port. If the port is not specified, 443 is used, like before.
The custom port can be specified in multiple ways. The cloudid is formed like this:
<host>:<es-id>:<kb-id>
. The port can be specified either in es-id or kb-id, or in the host section. If specified in both, the more specific one wins (i.e. es-id over host).Examples:
Results in:
Or:
Results in:
This is proposed fix for #7794.