Kibana:如何周期性地为 Dashboard 生成 PDF Report
转载自:https://blog.csdn.net/UbuntuTouch/article/details/108449775
按照上面的方式填写。记得把之前的 URL 拷贝到 webhook 下的 url 字段:
{
"trigger": {
"schedule": {
"interval": "2m"
}
},
"input": {
"none": {}
},
"condition": {
"always": {}
},
"actions": {
"my_webhook": {
"throttle_period_in_millis": 300000,
"webhook": {
"scheme": "http",
"host": "localhost",
"port": 5601,
"method": "post",
"path": "/api/reporting/generate/printablePdf",
"params": {
"jobParams": "(browserTimezone:Asia/Shanghai,layout:(dimensions:(height:1883.984375,width:1226.25),id:preserve_layout),objectType:dashboard,relativeUrls:!('/app/kibana#/dashboard/edf84fe0-e1a0-11e7-b6d5-4dc382ef7f5b?_g=(filters:!!(),refreshInterval:(pause:!!f,value:900000),time:(from:now-7d,to:now))&_a=(description:!'Analyze%20mock%20web%20traffic%20log%20data%20for%20Elastic!!!'s%20website!',filters:!!(),fullScreenMode:!!f,options:(hidePanelTitles:!!f,useMargins:!!t),query:(language:kuery,query:!'!'),timeRestore:!!t,title:!'%5BLogs%5D%20Web%20Traffic!',viewMode:view)'),title:'[Logs] Web Traffic')"
},
"headers": {
"kbn-xsrf": "reporting"
},
"auth": {
"basic": {
"username": "username",
"password": "::es_redacted::"
}
}
}
}
}
}
上面显示我们已经生产了一个 watcher。我们或者直接在 Dev Tools 中打入如下的命令:
PUT _watcher/watch/generate_pdf
{
"trigger": {
"schedule": {
"interval": "2m"
}
},
"input": {
"none": {}
},
"condition": {
"always": {}
},
"actions": {
"my_webhook": {
"throttle_period_in_millis": 300000,
"webhook": {
"url": "http://localhost:5601/api/reporting/generate/printablePdf?jobParams=%28browserTimezone%3AAsia%2FShanghai%2Clayout%3A%28dimensions%3A%28height%3A1883.984375%2Cwidth%3A1226.25%29%2Cid%3Apreserve_layout%29%2CobjectType%3Adashboard%2CrelativeUrls%3A%21%28%27%2Fapp%2Fkibana%23%2Fdashboard%2Fedf84fe0-e1a0-11e7-b6d5-4dc382ef7f5b%3F_g%3D%28filters%3A%21%21%28%29%2CrefreshInterval%3A%28pause%3A%21%21f%2Cvalue%3A900000%29%2Ctime%3A%28from%3Anow-7d%2Cto%3Anow%29%29%26_a%3D%28description%3A%21%27Analyze%2520mock%2520web%2520traffic%2520log%2520data%2520for%2520Elastic%21%21%21%27s%2520website%21%27%2Cfilters%3A%21%21%28%29%2CfullScreenMode%3A%21%21f%2Coptions%3A%28hidePanelTitles%3A%21%21f%2CuseMargins%3A%21%21t%29%2Cquery%3A%28language%3Akuery%2Cquery%3A%21%27%21%27%29%2CtimeRestore%3A%21%21t%2Ctitle%3A%21%27%255BLogs%255D%2520Web%2520Traffic%21%27%2CviewMode%3Aview%29%27%29%2Ctitle%3A%27%5BLogs%5D%20Web%20Traffic%27%29",
"method": "post",
"headers": {
"kbn-xsrf": "reporting"
},
"auth": {
"basic": {
"username": "username",
"password": "password"
}
}
}
}
}
}