javascript - 将日志从 Javascript 发送到 ElasticSearch
问题描述
是否有任何 Javascript api 允许我直接通过 axios post 或通过 Node JS 向 Elastic Search 发送帖子请求?这是将日志发送到 Elastic Search。
解决方案
您可以使用发送 POST 请求fetch
。
const response = await fetch(url, {
method: 'POST', // *GET, POST, PUT, DELETE, etc.
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data) // body data type must match "Content-Type" header
});
推荐阅读
- php - 致命错误:无法重新声明先前声明的函数()
- typescript - 在 TypeScript 中,有没有办法创建一个泛型 mixin 函数,它还允许在返回的类上使用泛型类型参数?
- java - 基于对象类覆盖java中的打印语句
- javascript - 将一维二进制数组拆分为仅由连续一维组成的二维数组
- python - 使用蒙特卡罗方法评估多变量的多重积分
- flutter - 在这种情况下,在颤振中构建 .apk 文件有什么问题?
- matplotlib - 重置(或赋值)到 matplotlib 中的 RadioButton
- c# - 根据列表内容显示/隐藏 DataGrid 列
- java - 为特定 DBMS(数据库引擎)动态设置 DataSource 的正确方法是什么?
- html - 如何匹配 HTML 输入并使用 CSS 选择样式