Skip to content
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
/dist/
coverage.html
coverage.out

check_elasticsearch*
TODO*
2 changes: 1 addition & 1 deletion internal/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func NewClient(urls []*url.URL, rt http.RoundTripper) *Client {
// Perform wraps the Client's HTTP call so that we can try all given
// nodes in case one node is not reachable
func (c *Client) Perform(req *http.Request) (*http.Response, error) {
originalPath := req.URL.String()
originalPath := req.URL.Path

for _, hostURL := range c.URLs {
// For each URL take the request, prepend the URL
Expand Down
2 changes: 1 addition & 1 deletion internal/elasticsearch/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type HealthResponse struct {
type SearchResponse struct {
Hits SearchHits `json:"hits"`
Error struct {
RootCause []ErrorRootCause `json:"root_cause"`
RootCause []ErrorRootCause `json:"root_cause,omitempty"`
}
}

Expand Down
41 changes: 41 additions & 0 deletions testdata/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
services:
es01:
image: docker.io/elasticsearch:9.3.0
container_name: es01
environment:
- node.name=es01
- cluster.name=check
- discovery.seed_hosts=es02,es03
- cluster.initial_master_nodes=es01,es02,es03
- bootstrap.memory_lock=true
- xpack.security.enabled=false
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ports:
- 9201:9200
es02:
image: docker.io/elasticsearch:9.3.0
container_name: es02
environment:
- node.name=es02
- cluster.name=check
- discovery.seed_hosts=es01,es03
- cluster.initial_master_nodes=es01,es02,es03
- bootstrap.memory_lock=true
- xpack.security.enabled=false
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ports:
- 9202:9200
es03:
image: docker.io/elasticsearch:9.3.0
container_name: es03
environment:
- node.name=es03
- cluster.name=check
- discovery.seed_hosts=es01,es02
- cluster.initial_master_nodes=es01,es02,es03
- bootstrap.memory_lock=true
- xpack.security.enabled=false
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ports:
- 9203:9200
14 changes: 14 additions & 0 deletions testdata/generate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generate an example doc

URL=http://localhost:9201

curl -X POST -H 'Content-Type: application/json' "${URL}/msg/_doc?pipeline=example-pipeline" -d '{
"body": "Example",
"severityNumber": 4,
"resource": {
"service.name": "node1"
},
"attributes": {
"team": "awesome"
}
}'
20 changes: 20 additions & 0 deletions testdata/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Setup an index and a pipeline

URL=http://localhost:9201

curl -s -k -X PUT -H 'Content-Type: application/json' "${URL}/_ingest/pipeline/example-pipeline" -d'
{
"description": "My optional pipeline description",
"processors": [
{
"set": {
"description": "My optional processor description",
"field": "my-long-field",
"value": 10
}
}
]
}
'

curl -s -k -X PUT -H 'Content-Type: application/json' "${URL}/msg"