天天看點

kibana 使用備忘錄

記錄如何使用kibana的操作

插件官方文檔:

https://kibana.gitbook.io/kibana-plugin-development-tutorial/

統一說明:以下指令均在kibana項目根目錄下執行

建立插件模闆:node scripts/generate_plugin plugin_name;

plugin_name為插件名,執行指令成功後會在plugins目錄下建立出相應的插件目錄;如執行上述的指令會出現plugin_name的檔案夾

--------------------------------- 樸素的分割線 -------------------------------------------

與elasticsearch通訊的api使用例子

export default function (server) {

//此處為擷取kibana連接配接elasticsearch用戶端,getCluster中的參數'data'為擷取elasticsearch的資料用戶端

const { callWithRequest } = server.plugins.elasticsearch.getCluster('data');

server.route({

path: '/api/test_plugin/example',
method: 'GET',
handler: async (request, reply) => {
  const params = {
    id: '1',
    index: 'ecommerce',
    type: 'product'
  };
  // callWithRequest 參數項可查閱/src/legacy/core_plugins/index.d.ts檔案,對源碼不太熟,并且vscode也不會配置出相應的代碼提示,導緻找了很久才找到
  const resp = await callWithRequest(request, "get", params);
  if (resp.errors) {
    server.log(['error'], 'error log msg');
    return { success : false,message : resp.items[0].index.error.reason};
  } else {
    return { success: true, data: resp };
  }
}           

});

}

kibana 配置檔案:

1、修改預設路由:在kibana配置檔案中添加:server.defaultRoute: /app/{插件名}

kibana 指令記錄(詳細可檢視根目錄下的CONTRIBUTING.md檔案):

1、kibana取消加載非開源第三方插件:yarn start --oss

npm 指令

1、npm 中 --save 參數會将所安裝的子產品或插件安裝到生産環境(寫入到package.json檔案中的dependencies标簽中)

--save-dev 則是安裝到開發環境中(寫入到package.json檔案中的devDependencies标簽中)           

繼續閱讀