Skip to content
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

Merged
merged 1 commit into from
Aug 25, 2017

Conversation

monicasarbu
Copy link
Contributor

@monicasarbu monicasarbu commented Aug 18, 2017

When loading the dashboards and the index-pattern, you can configure the name of the index under setup.dashboards.index:

$ ./metricbeat setup -E setup.dashboards.directory=_meta/kibana -E setup.dashboards.index=testbeat-* -e 

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

@monicasarbu monicasarbu added :Dashboards in progress Pull request is currently in progress. review and removed in progress Pull request is currently in progress. labels Aug 18, 2017
@monicasarbu monicasarbu force-pushed the configure_index_pattern branch 2 times, most recently from d35e030 to 6f08c02 Compare August 21, 2017 09:06
@monicasarbu monicasarbu added the in progress Pull request is currently in progress. label Aug 21, 2017
@monicasarbu monicasarbu force-pushed the configure_index_pattern branch from e3ac988 to 4c20a52 Compare August 21, 2017 11:29
@monicasarbu monicasarbu removed the in progress Pull request is currently in progress. label Aug 21, 2017
@monicasarbu
Copy link
Contributor Author

@ruflin Please let me know if this works for you.

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)
Copy link
Member

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?

@ruflin
Copy link
Member

ruflin commented Aug 22, 2017

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 Visualize: Error: in cell #1: Elasticsearch index not found: metricbeat*. Probably a different thing to overwrite.

@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.

@tsg tsg added the needs_backport PR is waiting to be backported to other branches. label Aug 24, 2017
@monicasarbu monicasarbu force-pushed the configure_index_pattern branch from 4c20a52 to 1b4440b Compare August 24, 2017 13:02
@monicasarbu
Copy link
Contributor Author

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.

@monicasarbu monicasarbu force-pushed the configure_index_pattern branch from dc443c0 to eafcedc Compare August 24, 2017 14:57
@monicasarbu
Copy link
Contributor Author

@ruflin I addressed your comments. The PR is ready for review.

Copy link
Member

@ruflin ruflin left a 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.

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)
Copy link
Member

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/

var vizContent common.MapStr
err = json.Unmarshal(reader, &vizContent)
if err != nil {
return fmt.Errorf("Failed to unmarshal vizualization content %s: %v", file, err)
Copy link
Member

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.

json.Unmarshal(reader, &jsonContent)
err = json.Unmarshal(reader, &jsonContent)
if err != nil {
return fmt.Errorf("failt to unmarshal the search content: %v", err)
Copy link
Member

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)
Copy link
Member

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 :-)

Copy link
Contributor Author

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.

var record common.MapStr
err := json.Unmarshal([]byte(savedObject), &record)
if err != nil {
return "", fmt.Errorf("Failed to unmarshal searchSourceJSON from search : %v", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

failed lower case

}
searchSourceJSON, err := json.Marshal(record)
if err != nil {
return "", fmt.Errorf("Failed to marshal searchSourceJSON: %v", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

failed lower case


body, err := json.Marshal(jsonBody)
if err != nil {
logp.Warn("Failed to json encode body (%v): %#v", err, jsonBody)
Copy link
Member

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?

@monicasarbu monicasarbu force-pushed the configure_index_pattern branch 2 times, most recently from e1b303c to 91e861b Compare August 25, 2017 09:46
@monicasarbu monicasarbu force-pushed the configure_index_pattern branch from 39d7b67 to 729dad6 Compare August 25, 2017 09:51
@tsg tsg merged commit 6130ef3 into elastic:master Aug 25, 2017
tsg pushed a commit to tsg/beats that referenced this pull request Aug 25, 2017
@tsg tsg removed the needs_backport PR is waiting to be backported to other branches. label Aug 25, 2017
ruflin pushed a commit that referenced this pull request Aug 25, 2017
leweafan pushed a commit to leweafan/beats that referenced this pull request Apr 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants