Skip to content
This repository has been archived by the owner on Apr 24, 2023. It is now read-only.

Commit

Permalink
🐞 Fixed when Index Pattern search did not work for an absolute wildca…
Browse files Browse the repository at this point in the history
…rd pattern `*`
  • Loading branch information
sherifabdlnaby committed Apr 7, 2020
1 parent a01bad2 commit ab8b795
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,18 @@ With Rubban *you can configure a _general_ pattern* like `logs-apache-access-?-*

## Docker

#### Docker
#### via Docker CLI
```
docker run --env='RUBBAN_KIBANA_HOST=https://kibana:5601' \
--env='RUBBAN_KIBANA_USER=elastic' \
--env='RUBBAN_KIBANA_PASSWORD=changeme' \
--env='RUBBAN_AUTOINDEXPATTERN_ENABLED=true' \
--env='RUBBAN_AUTOINDEXPATTERN_SCHEDULE=*/5 * * * *' \
--env='RUBBAN_AUTOINDEXPATTERN_GENERALPATTERNS=[{"pattern":"logs-apache-access-*-?","timeFieldName":"@timestamp"}]' \
sherifabdlnaby/rubban:latest
```

##### Docker Compose
##### via Docker Compose

`docker-compose up -d`

Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ services:
RUBBAN_KIBANA_HOST: "kibana:5601"
RUBBAN_KIBANA_USER: "elastic"
RUBBAN_KIBANA_PASSWORD: "changeme"
RUBBAN_AUTOINDEXPATTERN_ENABLED: 'true'
RUBBAN_AUTOINDEXPATTERN_SCHEDULE: '*/5 * * * *'
RUBBAN_AUTOINDEXPATTERN_GENERALPATTERNS: '[{"pattern":"logs-apache-access-*-?","timeFieldName":"@timestamp"}]'
7 changes: 1 addition & 6 deletions rubban/kibana/api_7.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ type FindIndexPatternResponse struct {
} `json:"hits"`
}

var alphaNumericRegex = regexp.MustCompile("[^a-zA-Z0-9]+")
var space = regexp.MustCompile(`\s+`)
var idxPatternID = regexp.MustCompile(`(index-pattern:)(.*)`)

//IndexPatterns Get IndexPatterns from kibana matching the supplied filter (support wildcards)
Expand All @@ -98,9 +96,6 @@ func (a *APIVer7) IndexPatterns(ctx context.Context, filter string, fields []str

var IndexPatterns = make([]IndexPattern, 0)

// Remove Non Alpha Numeric Chars AND Trim Duplicate Whitespaces.
indexPatternTrimd := space.ReplaceAllString(alphaNumericRegex.ReplaceAllString(filter, " "), " ")

requestBody := fmt.Sprintf(`{
"_source": ["index-pattern.title","index-pattern.timeFieldName"],
"size": 10000,
Expand Down Expand Up @@ -131,7 +126,7 @@ func (a *APIVer7) IndexPatterns(ctx context.Context, filter string, fields []str
"must_not": []
}
}
}`, indexPatternTrimd)
}`, filter)

resp, err := a.client.Post(ctx, "/api/console/proxy?path=.kibana/_search&method=POST", strings.NewReader(requestBody))
if err != nil {
Expand Down

0 comments on commit ab8b795

Please sign in to comment.