This repository has been archived by the owner on Sep 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #132 from mdelapenya/ingest-management-impl
[Ingest Manager] Add basic implementation for stand-alone mode scenarios
- Loading branch information
Showing
21 changed files
with
1,163 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
cli/config/compose/profiles/ingest-manager/docker-compose.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
version: '2.3' | ||
services: | ||
elasticsearch: | ||
healthcheck: | ||
test: ["CMD", "curl", "-f", "-u", "elastic:changeme", "http://127.0.0.1:9200/"] | ||
retries: 300 | ||
interval: 1s | ||
environment: | ||
- ES_JAVA_OPTS=-Xms1g -Xmx1g | ||
- network.host= | ||
- transport.host=127.0.0.1 | ||
- http.host=0.0.0.0 | ||
- indices.id_field_data.enabled=true | ||
- xpack.license.self_generated.type=trial | ||
- xpack.security.enabled=true | ||
- xpack.security.authc.api_key.enabled=true | ||
- ELASTIC_USERNAME=elastic | ||
- ELASTIC_PASSWORD=changeme | ||
image: "docker.elastic.co/elasticsearch/elasticsearch:8.0.0-SNAPSHOT" | ||
ports: | ||
- "9200:9200" | ||
kibana: | ||
depends_on: | ||
elasticsearch: | ||
condition: service_healthy | ||
package-registry: | ||
condition: service_healthy | ||
healthcheck: | ||
test: "curl -f http://localhost:5601/login | grep kbn-injected-metadata 2>&1 >/dev/null" | ||
retries: 600 | ||
interval: 1s | ||
image: "docker.elastic.co/kibana/kibana:8.0.0-SNAPSHOT" | ||
ports: | ||
- "5601:5601" | ||
volumes: | ||
- ${kibanaConfigPath}:/usr/share/kibana/config/kibana.yml | ||
package-registry: | ||
image: docker.elastic.co/package-registry/package-registry:master | ||
healthcheck: | ||
test: ["CMD", "curl", "-f", "http://localhost:8080"] | ||
retries: 300 | ||
interval: 1s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
cli/config/compose/services/elastic-agent/docker-compose.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
version: '2.3' | ||
services: | ||
elastic-agent: | ||
image: docker.elastic.co/beats/elastic-agent:${elasticAgentTag:-8.0.0-SNAPSHOT} | ||
depends_on: | ||
elasticsearch: | ||
condition: service_healthy | ||
kibana: | ||
condition: service_healthy | ||
environment: | ||
- "KIBANA_HOST=http://${kibanaHost:-kibana}:${kibanaPort:-5601}" | ||
volumes: | ||
- "${elasticAgentConfigFile}:/usr/share/elastic-agent/elastic-agent.yml" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package shell | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"io" | ||
"io/ioutil" | ||
"net/http" | ||
|
||
log "github.com/sirupsen/logrus" | ||
) | ||
|
||
// HTTPRequest configures an HTTP request | ||
type HTTPRequest struct { | ||
BasicAuthUser string | ||
BasicAuthPassword string | ||
Headers map[string]string | ||
method string | ||
Payload []byte | ||
URL string | ||
} | ||
|
||
// Get executes a GET request | ||
func Get(r HTTPRequest) (string, error) { | ||
r.method = "GET" | ||
|
||
return request(r) | ||
} | ||
|
||
// Post executes a POST request | ||
func Post(r HTTPRequest) (string, error) { | ||
r.method = "POST" | ||
|
||
return request(r) | ||
} | ||
|
||
// Post executes a request | ||
func request(r HTTPRequest) (string, error) { | ||
log.WithFields(log.Fields{ | ||
"method": r.method, | ||
"url": r.URL, | ||
}).Debug("Executing request") | ||
|
||
var body io.Reader | ||
if r.Payload != nil { | ||
body = bytes.NewReader(r.Payload) | ||
} else { | ||
body = nil | ||
} | ||
|
||
req, err := http.NewRequest(r.method, r.URL, body) | ||
if err != nil { | ||
log.WithFields(log.Fields{ | ||
"error": err, | ||
"method": r.method, | ||
"url": r.URL, | ||
}).Warn("Error creating request") | ||
return "", err | ||
} | ||
|
||
if r.Headers != nil { | ||
for k, v := range r.Headers { | ||
req.Header.Set(k, v) | ||
} | ||
} | ||
|
||
if r.BasicAuthUser != "" { | ||
req.SetBasicAuth(r.BasicAuthUser, r.BasicAuthPassword) | ||
} | ||
|
||
resp, err := http.DefaultClient.Do(req) | ||
if err != nil { | ||
log.WithFields(log.Fields{ | ||
"error": err, | ||
"method": r.method, | ||
"url": r.URL, | ||
}).Warn("Error executing request") | ||
return "", err | ||
} | ||
defer resp.Body.Close() | ||
|
||
bodyBytes, err := ioutil.ReadAll(resp.Body) | ||
if err != nil { | ||
log.WithFields(log.Fields{ | ||
"error": err, | ||
"method": r.method, | ||
"url": r.URL, | ||
}).Warn("Could not read response body") | ||
return "", err | ||
} | ||
bodyString := string(bodyBytes) | ||
|
||
// http.Status ==> [2xx, 4xx) | ||
if resp.StatusCode >= http.StatusOK && resp.StatusCode < http.StatusBadRequest { | ||
return bodyString, nil | ||
} | ||
|
||
return bodyString, fmt.Errorf("%s request failed with %d", r.method, resp.StatusCode) | ||
} |
Oops, something went wrong.