diff --git a/README.md b/README.md index 3a7d65e..fdae9e6 100644 --- a/README.md +++ b/README.md @@ -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` diff --git a/docker-compose.yml b/docker-compose.yml index 3e8eede..45d438d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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"}]' diff --git a/rubban/kibana/api_7.go b/rubban/kibana/api_7.go index c518cdc..71022e4 100644 --- a/rubban/kibana/api_7.go +++ b/rubban/kibana/api_7.go @@ -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) @@ -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, @@ -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 {