-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change index name in the dashboards and index-pattern #4949
Conversation
d35e030
to
6f08c02
Compare
e3ac988
to
4c20a52
Compare
@ruflin Please let me know if this works for you. |
libbeat/dashboards/kibana_loader.go
Outdated
if err != nil { | ||
return fmt.Errorf("fail to read index-pattern: %v", err) | ||
} | ||
|
||
return loader.client.ImportJSON(importAPI, params, bytes.NewBuffer(content)) | ||
var indexContent common.MapStr | ||
json.Unmarshal(reader, &indexContent) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add an error check here?
I tested this and encountered one issues: It seems to work with most dashboards but not the ones that include timelion. There I get the error @monicasarbu I would be ok to even merge as is and "document" that it will not work with Timelion queries as this is already a huge step forward. |
4c20a52
to
1b4440b
Compare
As we are planning to redo our dashboards that are based on Timelion, I suggest having support for changing the index name only for the dashboards that are not based on Timelion visualizations. |
dc443c0
to
eafcedc
Compare
@ruflin I addressed your comments. The PR is ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I left you some minor "style" comments. Could you rebase on master?
I didn't test again manually as it seems the last commit was mainly rebase.
libbeat/dashboards/es_loader.go
Outdated
json.Unmarshal([]byte(jsonContent.PanelsJSON), &widgets) | ||
err = json.Unmarshal([]byte(jsonContent.PanelsJSON), &widgets) | ||
if err != nil { | ||
return fmt.Errorf("filt to unmatshal panels content: %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/filt/fail/
s/unmatshal/unmarshal/
libbeat/dashboards/es_loader.go
Outdated
var vizContent common.MapStr | ||
err = json.Unmarshal(reader, &vizContent) | ||
if err != nil { | ||
return fmt.Errorf("Failed to unmarshal vizualization content %s: %v", file, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We normally have errors that are returned starting lower case.
libbeat/dashboards/es_loader.go
Outdated
json.Unmarshal(reader, &jsonContent) | ||
err = json.Unmarshal(reader, &jsonContent) | ||
if err != nil { | ||
return fmt.Errorf("failt to unmarshal the search content: %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/failt/failed/
var indexContent common.MapStr | ||
err = json.Unmarshal(reader, &indexContent) | ||
if err != nil { | ||
return fmt.Errorf("fail to unmarshal the index content: %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/fail/failed/ -> not sure which one we shoud use, but we should be consistent :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I always using fail
instead of failed
. Not sure what is more widely used.
libbeat/dashboards/modify_json.go
Outdated
var record common.MapStr | ||
err := json.Unmarshal([]byte(savedObject), &record) | ||
if err != nil { | ||
return "", fmt.Errorf("Failed to unmarshal searchSourceJSON from search : %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
failed lower case
libbeat/dashboards/modify_json.go
Outdated
} | ||
searchSourceJSON, err := json.Marshal(record) | ||
if err != nil { | ||
return "", fmt.Errorf("Failed to marshal searchSourceJSON: %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
failed lower case
libbeat/setup/kibana/client.go
Outdated
|
||
body, err := json.Marshal(jsonBody) | ||
if err != nil { | ||
logp.Warn("Failed to json encode body (%v): %#v", err, jsonBody) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be an Err instead of Warning?
e1b303c
to
91e861b
Compare
39d7b67
to
729dad6
Compare
…rds (elastic#4949) (cherry picked from commit 6130ef3)
…rds (elastic#4949) (elastic#5018) (cherry picked from commit 36932d6)
When loading the dashboards and the index-pattern, you can configure the name of the index under
setup.dashboards.index
:This replaces the index name from the index-pattern and all the dashboards.
This change is done for loading the 5.x and 6.x dashboards.
Note This doesn't work for dashboards containing the Timelion visualizations.
cc-ed @ruflin