Skip to content

Commit d35fa86

Browse files
authored
Add logstash to stack as an optional service (#1458)
Logstash is added as an optional service as part of 'elastic-package stack' command. It is controlled by the profile config options.
1 parent 6f5bf36 commit d35fa86

File tree

34 files changed

+2998
-2
lines changed

34 files changed

+2998
-2
lines changed

.buildkite/pipeline.trigger.integration.tests.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ CHECK_PACKAGES_TESTS=(
3434
test-check-packages-with-kind
3535
test-check-packages-with-custom-agent
3636
test-check-packages-benchmarks
37+
test-check-packages-with-logstash
3738
)
3839
for test in ${CHECK_PACKAGES_TESTS[@]}; do
3940
echo " - label: \":go: Running integration test: ${test}\""

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ test-stack-command-8x:
7070

7171
test-stack-command: test-stack-command-default test-stack-command-7x test-stack-command-800 test-stack-command-8x
7272

73-
test-check-packages: test-check-packages-with-kind test-check-packages-other test-check-packages-parallel test-check-packages-with-custom-agent test-check-packages-benchmarks test-check-packages-false-positives
73+
test-check-packages: test-check-packages-with-kind test-check-packages-other test-check-packages-parallel test-check-packages-with-custom-agent test-check-packages-benchmarks test-check-packages-false-positives test-check-packages-with-logstash
7474

7575
test-check-packages-with-kind:
7676
PACKAGE_TEST_TYPE=with-kind ./scripts/test-check-packages.sh
@@ -81,6 +81,9 @@ test-check-packages-other:
8181
test-check-packages-false-positives:
8282
PACKAGE_TEST_TYPE=false_positives ./scripts/test-check-false-positives.sh
8383

84+
test-check-packages-with-logstash:
85+
PACKAGE_TEST_TYPE=with-logstash ./scripts/test-check-packages.sh
86+
8487
test-check-packages-benchmarks:
8588
PACKAGE_TEST_TYPE=benchmarks ./scripts/test-check-packages.sh
8689

cmd/stack.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ var availableServices = map[string]struct{}{
2424
"fleet-server": {},
2525
"kibana": {},
2626
"package-registry": {},
27+
"logstash": {},
2728
}
2829

2930
const stackLongDescription = `Use this command to spin up a Docker-based Elastic Stack consisting of Elasticsearch, Kibana, and the Package Registry. By default the latest released version of the stack is spun up but it is possible to specify a different version, including SNAPSHOT versions by appending --version <version>.

docs/howto/custom_images.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ The current images that could be overwritten are:
2020
| Elasticsearch | ELASTICSEARCH_IMAGE_REF_OVERRIDE | elasticsearch |
2121
| Kibana | KIBANA_IMAGE_REF_OVERRIDE | kibana |
2222
| Elastic Agent | ELASTIC_AGENT_IMAGE_REF_OVERRIDE | elastic-agent |
23+
| Logstash | LOGSTASH_IMAGE_REF_OVERRIDE | logstash |
2324

2425

2526
For the following two examples, it will be used as example overwriting elastic-agent image.

docs/howto/system_testing.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,25 @@ Example `expected_errors` file content:
579579
<testcase name=\"system test: pagination\" classname=\"httpjson_false_positive_asserts.generic\" time=\".*\"> * <failure>observed hit count 4 did not match expected hit count 2</failure>
580580
```
581581

582+
### System testing with logstash
583+
584+
It is possible to test packages that output to Logstash which in turn publishes events to Elasticsearch.
585+
A profile config option `stack.logstash_enabled` has been added to profile configuration.
586+
587+
When this profile config is enabled
588+
- Logstash output is added in Fleet with id `fleet-logstash-output`
589+
- Logstash service is created in the stack which reads from `elastic-agent` input and outputs to `elasticsearch`.
590+
- Logstash is also configured with `elastic-integration` plugin. Once configured to point to an Elasticsearch cluster, this filter will detect which ingest pipeline (if any) should be executed for each event, auto-detecting the event’s data-stream and its default pipeline.
591+
592+
A sample workflow would look like:
593+
594+
- You can [create](https://github.com/elastic/elastic-package#elastic-package-profiles-create) a new profile / [use existing profile](https://github.com/elastic/elastic-package#elastic-package-profiles-use) to test this.
595+
- Navigate to `~/.elastic-package/profiles/<profilename>/`.
596+
- Rename `config.yml.example` to `config.yml` [ If config is not used before ]
597+
- Add the following line (or uncomment if present) `stack.logstash_enabled: true`
598+
- Run `elastic-package stack up -d -v`
599+
- Navigate to the package folder in integrations and run `elastic-package test system -v`
600+
582601
## Continuous Integration
583602

584603
`elastic-package` runs a set of system tests on some [dummy packages](https://github.com/elastic/elastic-package/tree/main/test/packages) to ensure it's functionalities work as expected. This allows to test changes affecting package testing within `elastic-package` before merging and releasing the changes.

internal/install/application_configuration.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const (
2929
elasticAgentCompleteImageName = "docker.elastic.co/elastic-agent/elastic-agent-complete"
3030
elasticsearchImageName = "docker.elastic.co/elasticsearch/elasticsearch"
3131
kibanaImageName = "docker.elastic.co/kibana/kibana"
32+
logstashImageName = "docker.elastic.co/logstash/logstash"
3233

3334
applicationConfigurationYmlFile = "config.yml"
3435
)
@@ -87,6 +88,7 @@ func (s stack) ImageRefOverridesForVersion(version string) ImageRefs {
8788
ElasticAgent: checkImageRefOverride("ELASTIC_AGENT_IMAGE_REF_OVERRIDE", stringOrDefault(appConfigImageRefs.ElasticAgent, "")),
8889
Elasticsearch: checkImageRefOverride("ELASTICSEARCH_IMAGE_REF_OVERRIDE", stringOrDefault(appConfigImageRefs.Elasticsearch, "")),
8990
Kibana: checkImageRefOverride("KIBANA_IMAGE_REF_OVERRIDE", stringOrDefault(appConfigImageRefs.Kibana, "")),
91+
Logstash: checkImageRefOverride("LOGSTASH_IMAGE_REF_OVERRIDE", stringOrDefault(appConfigImageRefs.Logstash, "")),
9092
}
9193
}
9294

@@ -95,6 +97,7 @@ type ImageRefs struct {
9597
ElasticAgent string `yaml:"elastic-agent"`
9698
Elasticsearch string `yaml:"elasticsearch"`
9799
Kibana string `yaml:"kibana"`
100+
Logstash string `yaml:"logstash"`
98101
}
99102

100103
// AsEnv method returns key=value representation of image refs.
@@ -103,6 +106,7 @@ func (ir ImageRefs) AsEnv() []string {
103106
vars = append(vars, "ELASTIC_AGENT_IMAGE_REF="+ir.ElasticAgent)
104107
vars = append(vars, "ELASTICSEARCH_IMAGE_REF="+ir.Elasticsearch)
105108
vars = append(vars, "KIBANA_IMAGE_REF="+ir.Kibana)
109+
vars = append(vars, "LOGSTASH_IMAGE_REF="+ir.Logstash)
106110
return vars
107111
}
108112

@@ -112,6 +116,7 @@ func (ac *ApplicationConfiguration) StackImageRefs(version string) ImageRefs {
112116
refs.ElasticAgent = stringOrDefault(refs.ElasticAgent, fmt.Sprintf("%s:%s", selectElasticAgentImageName(version), version))
113117
refs.Elasticsearch = stringOrDefault(refs.Elasticsearch, fmt.Sprintf("%s:%s", elasticsearchImageName, version))
114118
refs.Kibana = stringOrDefault(refs.Kibana, fmt.Sprintf("%s:%s", kibanaImageName, version))
119+
refs.Logstash = stringOrDefault(refs.Logstash, fmt.Sprintf("%s:%s", logstashImageName, version))
115120
return refs
116121
}
117122

internal/kibana/policies.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ type Policy struct {
2121
Revision int `json:"revision,omitempty"`
2222
MonitoringEnabled []string `json:"monitoring_enabled,omitempty"`
2323
MonitoringOutputID string `json:"monitoring_output_id,omitempty"`
24+
DataOutputID string `json:"data_output_id,omitempty"`
2425
}
2526

2627
// CreatePolicy persists the given Policy in Fleet.

internal/profile/_static/config.yml.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@
1010
# Region where the Serverless project is going to be created
1111
# stack.serverless.region: aws-us-east-1
1212

13+
## Enable logstash for testing
14+
# Flag to enable logstash in elastic-package stack profile config
15+
# stack.logstash_enabled: true
16+

internal/profile/_testdata/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# An expected setting.
22
stack.geoip_dir: "/home/foo/Documents/ingest-geoip"
3+
stack.logstash_enabled: true
34

45
# An empty string, should exist, but return empty.
56
other.empty: ""

internal/profile/config_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ func TestLoadProfileConfig(t *testing.T) {
4747
expected: "false",
4848
found: true,
4949
},
50+
{
51+
name: "stack.logstash_enabled",
52+
expected: "true",
53+
found: true,
54+
},
5055
{
5156
name: "not.present",
5257
found: false,

0 commit comments

Comments
 (0)