TomonoriSoejima / Tejun

notes related to working cases
5 stars 3 forks source link

How to test filebeat dashboard import/export #105

Open TomonoriSoejima opened 1 year ago

TomonoriSoejima commented 1 year ago

1 setup dashboard

./filebeat setup

make sure filebeat.yml looks like this.

setup.dashboards.enabled: true
cloud.id: clean:YXNpYS1ub3J0aGVhc3QxLmdjcC5jbG91ZC5lcy5pbzo0NDMkZDdhNjMwYTc1NGYwNDJkZjk5YTQxMzU5NmUwYjRhNjUkNTU3YjUxZDhiZjEzNGY2MDgwOTFkMjAwZDUzOTdmZGQ=
cloud.auth: 'elastic:<password>'

2 find dashboard you want to export

GET kbn:/api/saved_objects/_find?type=search&type=visualization&type=dashboard

image

3 export and verify

[surfer-3:filebeat-8.6.0-darwin-x86_64]$ ./filebeat export dashboard -id=046212a0-a2a1-11e7-928f-5dbe6f6f5519-ecs --folder=./kokode
[surfer-3:filebeat-8.6.0-darwin-x86_64]$ tree kokode/
kokode/
└── _meta
    └── kibana
        └── 8
            ├── dashboard
            │   └── 046212a0-a2a1-11e7-928f-5dbe6f6f5519-ecs.json
            ├── search
            │   ├── 6d9e66d0-a1f0-11e7-928f-5dbe6f6f5519-ecs.json
            │   └── 9eb25600-a1f0-11e7-928f-5dbe6f6f5519-ecs.json
            └── visualization
                ├── 1cfb1a80-a1f4-11e7-928f-5dbe6f6f5519-ecs.json
                └── 97109780-a2a5-11e7-928f-5dbe6f6f5519-ecs.json

7 directories, 5 files
[surfer-3:filebeat-8.6.0-darwin-x86_64]$  

4 delete the dashboard.

DELETE kbn:/api/saved_objects/dashboard/046212a0-a2a1-11e7-928f-5dbe6f6f5519-ecs

5 import the dashboard

[surfer-3:filebeat-8.6.0-darwin-x86_64]$ ./filebeat setup --dashboards -E setup.dashboards.directory=./kokode/_meta/kibana
Loading dashboards (Kibana must be running and reachable)
Skipping loading dashboards, error importing Kibana dashboards: fail to import the dashboards in Kibana: Error importing directory ./kokode/_meta/kibana: No directory kokode/_meta/kibana/7
[surfer-3:filebeat-8.6.0-darwin-x86_64]$ 
TomonoriSoejima commented 1 year ago
id="046212a0-a2a1-11e7-928f-5dbe6f6f5519-ecs"

./filebeat export dashboard -id=$id --folder=$id

# delete the dashboard from Kibana gui if you want.

./filebeat setup --dashboards -E setup.dashboards.directory=$id/_meta/kibana

echo apply workaround

cp -r $id/_meta/kibana/8 $id/_meta/kibana/7

./filebeat setup --dashboards -E setup.dashboards.directory=$id/_meta/kibana