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

Allow custom port in cloud.id #7887

Merged
merged 4 commits into from
Aug 7, 2018
Merged

Conversation

tsg
Copy link
Contributor

@tsg tsg commented Aug 6, 2018

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:

'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

This is proposed fix for #7794.

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.
@tsg tsg added bug discuss Issue needs further discussion. needs_backport PR is waiting to be backported to other branches. review labels Aug 6, 2018
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"
Copy link
Contributor

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.

Copy link
Contributor

@ph ph left a 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.

@@ -31,6 +31,8 @@ import (
"github.com/elastic/beats/libbeat/logp"
)

const DefaultCloudPort = "443"

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

idx := strings.LastIndex(word, ":")
if idx >= 0 {
return word[:idx], word[idx+1:]
} else {

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

@tsg tsg added v6.4.0 and removed discuss Issue needs further discussion. labels Aug 7, 2018
@tsg
Copy link
Contributor Author

tsg commented Aug 7, 2018

@ph I made things more flexible to also allow individual ES and KB port.

Copy link
Contributor

@ph ph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ph ph merged commit daaca33 into elastic:master Aug 7, 2018
@tsg tsg added v6.4.0 and removed needs_backport PR is waiting to be backported to other branches. labels Aug 8, 2018
@tsg tsg added the v6.5.0 label Aug 8, 2018
tsg added a commit to tsg/beats that referenced this pull request Aug 8, 2018
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)
tsg added a commit to tsg/beats that referenced this pull request Aug 8, 2018
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)
kvch pushed a commit that referenced this pull request Aug 8, 2018
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)
kvch pushed a commit that referenced this pull request Aug 8, 2018
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)
leweafan pushed a commit to leweafan/beats that referenced this pull request Apr 28, 2023
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants