当前位置: 首页 > news >正文

(001)window 使用 OpenObserve

文章目录

  • 安装
  • 上传数据
  • 报错
  • 附录

安装

1.下载安装包:
在这里插入图片描述2. window 设置环境变量:

ZO_ETCD_COMMAND_TIMEOUT = 600 
ZO_ETCD_CONNECT_TIMEOUT = 600
ZO_ETCD_LOCK_WAIT_TIMEOUT = 600
ZO_INGEST_ALLOWED_UPTO = 10000
ZO_ROOT_USER_EMAIL = 422615924@qq.com
ZO_ROOT_USER_PASSWORD = 8R4VMmC1Su975e026Ln3
  1. 直接运行 openobserve.exe 启动程序:

在这里插入图片描述

上传数据

1.Gradle 需要的安装包:

 		// https://mvnrepository.com/artifact/cn.hutool/hutool-allimplementation group: 'cn.hutool', name: 'hutool-all', version: '5.8.23'// https://mvnrepository.com/artifact/com.alibaba.fastjson2/fastjson2implementation group: 'com.alibaba.fastjson2', name: 'fastjson2', version: '2.0.45'implementation group: 'org.slf4j', name: 'log4j-over-slf4j', version: '1.7.25'implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'implementation group: 'ch.qos.logback', name: 'logback-core', version: '1.2.3'implementation group: 'ch.qos.logback', name: 'logback-access', version: '1.2.3'// https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttpimplementation group: 'com.squareup.okhttp3', name: 'okhttp', version: '5.0.0-alpha.12'implementation group: 'com.alibaba', name: 'druid', version: '1.1.9'

2.数据目录和内容格式:
在这里插入图片描述

在这里插入图片描述
3.上传代码:

package org.example;import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import okhttp3.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;import java.io.File;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.*;/*** 008*/
public class UploadOpenObserve {private static final Logger logger = LoggerFactory.getLogger(UploadOpenObserve.class);private static String targetDirectory = "D:\\S3log\\unzip12\\";private static ConcurrentHashMap<String, String> failFile = new ConcurrentHashMap<>();private static String mail = "422615924@qq.com";private static String password = "4MHyN8BGMaCRyEen";private static String credential = Credentials.basic("422615924@qq.com", "4MHyN8BGMaCRyEen");private static volatile OkHttpClient okHttpClient;private static String buyStreamName = "buy105";private static String payStreamName = "pay105";public static void main(String[] args) {uploadBuyAndPay();}private static void upload_jpy20231216(){List<File> directories = listDirectory(targetDirectory);for (int i = 0; i < directories.size(); i++) {File file = directories.get(i);if (file.getName().startsWith("20231215_") || file.getName().startsWith("20231216_")){logger.debug(file.getName());uploadDirectory_jpy("jpy20231216_002", file);}}}private static void uploadBuyAndPay(){List<File> directories = listDirectory(targetDirectory);ExecutorService executorService = Executors.newFixedThreadPool(Math.max(2, Runtime.getRuntime().availableProcessors() / 2));CountDownLatch countDownLatch = new CountDownLatch(directories.size());for (int i = 0; i < directories.size(); i++) {final File file = directories.get(i);final int j = i;executorService.submit(() -> {try {uploadDirectory(file);}finally {countDownLatch.countDown();logger.debug("目录传输完成: {}, {}/{}", file.getName(), j, directories.size());}});}try {countDownLatch.await();} catch (Exception e) {logger.error("", e);} finally {executorService.shutdown();}logger.debug("任务执行完成.");}private static List<File> listDirectory(String targetDirectory) {File[] files = FileUtil.ls(targetDirectory);List<File> arrFiles = new ArrayList<>();for (int i = 0; i < files.length; i++) {if (files[i].isDirectory()) {arrFiles.add(files[i]);}}return arrFiles;}private static void checkDirectoryFile(File directory) {if (!directory.isDirectory()) {logger.error("not a directory {}", directory.getName());return;}File[] files = FileUtil.ls(directory.getPath());for (int i = 0; i < files.length; i++) {String name = files[i].getName();if (!name.startsWith("2023") && !name.startsWith("JPY")) {logger.error("error file {}", name);}}}private static void uploadDirectory_jpy(String streamName, File directory) {if (!directory.isDirectory()) {logger.error("not a directory {}", directory.getName());return;}File[] files = FileUtil.ls(directory.getPath());for (int i = 0; i < files.length; i++) {String name = files[i].getName();if (!name.startsWith("JPY")) {continue;}uploadFile(directory, streamName, files[i]);}}private static void uploadDirectory(File directory) {if (!directory.isDirectory()) {logger.error("not a directory {}", directory.getName());return;}
//        if (FileUtil.exist(StrUtil.format("{}/upload", directory.getPath()))) {
//            logger.debug("has upload {}", directory.getPath());
//            return;
//        }File[] files = FileUtil.ls(directory.getPath());for (int i = 0; i < files.length; i++) {String name = files[i].getName();if (name.startsWith("JPY")) {continue;}if (name.endsWith("Buy.log")) {uploadFile(directory, buyStreamName, files[i]);} else if (name.endsWith("Pay.log")) {uploadFile(directory, payStreamName, files[i]);}}}public static OkHttpClient getOkHttpInstance(){if (null == okHttpClient){synchronized (UploadOpenObserve.class){if (okHttpClient == null){okHttpClient = new OkHttpClient.Builder().callTimeout(7200, TimeUnit.SECONDS).connectTimeout(3600, TimeUnit.SECONDS).readTimeout(3600, TimeUnit.SECONDS).writeTimeout(3600, TimeUnit.SECONDS).connectionPool(new ConnectionPool(32, 5, TimeUnit.MINUTES)).build();return okHttpClient;}}}return okHttpClient;}private static void uploadFile(File directory, String streamName, File file) {String url = StrUtil.format("http://localhost:5080/api/default/{}/_json", streamName);List<String> lines = FileUtil.readLines(file, StandardCharsets.UTF_8);lines.removeIf(item -> !item.startsWith("{"));if (lines.isEmpty()) {return;}List<JSONObject> jsonObjects = new ArrayList<>();lines.forEach(item -> {try {JSONObject jsonObject = JSONObject.parseObject(item);if (jsonObject.containsKey("JSTDate")){String value = jsonObject.getString("JSTDate");jsonObject.put("jst_time", value.substring(0, 8));jsonObject.put("jst_dateday", value.substring(0, 6));jsonObject.put("jst_day", value.substring(6, 8));}jsonObjects.add(jsonObject);} catch (Exception e){logger.error("", e);}});if (jsonObjects.isEmpty())return;RequestBody requestBody = RequestBody.create(JSON.toJSONString(jsonObjects),  MediaType.parse("application/x-www-form-urlencoded"));Request request = new Request.Builder().addHeader("Authorization", credential).url(url).post(requestBody).build();boolean success = false;try (Response response = getOkHttpInstance().newCall(request).execute()) {success = response.isSuccessful();} catch (Exception e) {e.printStackTrace();logger.debug("upload fail {}, reason {}", file.getName(), e.getMessage());} finally {if (success){FileUtil.touch(StrUtil.format("{}/upload", directory.getPath()));//                String res = response.body().string();//            logger.debug("upload success {}, {}", file.getName(), JSON.toJSONString(res));} else {failFile.put(file.getName(), "true");}}}/*** curl -u 422615924@qq.com:8R4VMmC1Su975e026Ln3 -k https://api.openobserve.ai/api/peilin_organization_3737_H87YxMBFXYifSaV/default/_json* -d '[{"level":"info","job":"test","log":"test message for openobserve","_timestamp": 1704958559370}]'*/private static void testUploadJson() {String url = "https://api.openobserve.ai/api/peilin_organization_3737_H87YxMBFXYifSaV/test1/_json";HttpRequest request = HttpUtil.createPost(url);request.basicAuth("422615924@qq.com", "8R4VMmC1Su975e026Ln3");request.body("[{\"level\":\"inf\",\"jo\":43212,\"log\":\"test message for openobserve\"}]", "application/json");HttpResponse response = request.execute();logger.info("{}", JSON.toJSON(response.body()));}
}

报错

一、 发送的数据格式错误:
在这里插入图片描述
二、 数据的太旧了:
在这里插入图片描述

附录

[1] Github openobserve/openobserve
[2] 官网手册 openobserve

相关文章:

(001)window 使用 OpenObserve

文章目录 安装上传数据报错附录 安装 1.下载安装包&#xff1a; 2. window 设置环境变量&#xff1a; ZO_ETCD_COMMAND_TIMEOUT 600 ZO_ETCD_CONNECT_TIMEOUT 600 ZO_ETCD_LOCK_WAIT_TIMEOUT 600 ZO_INGEST_ALLOWED_UPTO 10000 ZO_ROOT_USER_EMAIL 422615924qq.com ZO_…...

linux发送http请求命令

一、http get请求 1、curl命令不带参 curl “http://www.baidu.com” 如果这里的URL指向的是一个文件或者一幅图都可以直接下载到本地 curl -i “http://www.baidu.com” 显示全部信息 curl -l “http://www.baidu.com” 只显示头部信息 curl -v “http://www.baidu.com”…...

JVM实战(19)——JVM调优工具概述

作者简介&#xff1a;大家好&#xff0c;我是smart哥&#xff0c;前中兴通讯、美团架构师&#xff0c;现某互联网公司CTO 联系qq&#xff1a;184480602&#xff0c;加我进群&#xff0c;大家一起学习&#xff0c;一起进步&#xff0c;一起对抗互联网寒冬 学习必须往深处挖&…...

Windows10无法访问github

亲测有效 1、修改hosts文件 如果电脑是Windows系统&#xff1a;打开 C:\Windows\System32\drivers\etc 找到hosts文件&#xff0c;将对应的Host地址修改为&#xff1a; #github 140.82.112.4 github.com 199.232.69.194 github.global.ssl.fastly.net 如果在保存hosts时遇到…...

GIT 分支管理办法(二)

GIT 分支管理办法&#xff08;二&#xff09; 一. 大型项目分支管理中存在的痛点 大型项目中需求的上线存在很大的不确定性&#xff0c;而且往往存在多版本、多团队、多开发并行的情况。尤其是大型企业对上线分支中编号的管理十分严苛&#xff0c;严禁夹带上线。这时对于开发…...

Vue面试之Mixins

Vue面试之Mixins 定义Mixins使用Mixins全局MixinsMixins合并策略注意事项命名冲突&#xff1a;过度使用 最近在整理一些前端面试中经常被问到的问题&#xff0c;分为vue相关、react相关、js相关、react相关等等专题&#xff0c;可持续关注后续内容&#xff0c;会不断进行整理~ …...

YOLOv8改进 | 主干篇 | EfficientViT高效的特征提取网络完爆MobileNet系列(轻量化网络结构)

一、本文介绍 本文给大家带来的改进机制是主干网络&#xff0c;一个名字EfficientViT的特征提取网络(和之前发布的只是同名但不是同一个)&#xff0c;其基本原理是提升视觉变换器在高效处理高分辨率视觉任务的能力。它采用了创新的建筑模块设计&#xff0c;包括三明治布局和级联…...

分布式限流要注意的问题

本文已收录至我的个人网站&#xff1a;程序员波特&#xff0c;主要记录Java相关技术系列教程&#xff0c;共享电子书、Java学习路线、视频教程、简历模板和面试题等学习资源&#xff0c;让想要学习的你&#xff0c;不再迷茫。 为什么需要匀速限流 同学们回想一下在Guava小节里…...

git将一个远程分支的部分修改提交到另一个远程分支

将一个远程分支的部分修改提交到另一个远程分支 将一个远程分支的部分修改提交到另一个远程分支&#xff0c;可以使用 git cherry-pick 命令。这个命令可以选择特定的提交&#xff08;commit&#xff09;从一个分支应用到另一个分支。 切换到目标本地分支&#xff1a; 首先&am…...

promise是什么怎么使用

Promise 是一种 JavaScript 中的对象&#xff0c;用于处理异步操作。它表示一个最终可能完成&#xff08;解析&#xff09;或失败&#xff08;拒绝&#xff09;的操作&#xff0c;以及其结果值。 Promise 有三种状态&#xff1a; Pending&#xff08;待定&#xff09;&#x…...

国际版WPS Office 18.6.1

【应用名称】&#xff1a;WPS Office 【适用平台】&#xff1a;#Android 【软件标签】&#xff1a;#WPS 【应用版本】&#xff1a;18.6.1 【应用大小】&#xff1a;160MB 【软件说明】&#xff1a;软件日常更新。WPS Office是使用人数最多的移动办公软件。独有手机阅读模式…...

记录一次数据中包含转义字符\引发的bug

后端返回给前端的数据是: { "bizObj": { "current": 1, "orders": [ ], "pages": 2, "records": [ { "from": "1d85b8a4bd33aaf99adc2e71ef02960e", …...

网络协议:ICMP协议及实用工具介绍

目 录 一、ICMP介绍 1、概述 2、功能 3、特点 二、ICMP的数据报文 三、ICMP相关工具 四、主要ICMP工具应用 1、Ping 2、Traceroute &#xff08;1&#xff09; 方法1&#xff1a; &#xff08;2&#xff09;方法2&#xff1a; 3、Nmap 一、ICMP介绍 1、概述 …...

Hyper-V如何设置网络-虚拟交换机设置

Hyper-V如何设置网络-虚拟交换机设置 缘起虚拟交换机类型1. 外部交换机&#xff1b;2. 内部交换机&#xff1b;3. 专用交换机&#xff1b;4.default switch&#xff1b; 虚拟机上openwrt多种网络连接方式 缘起 发现win10还有个虚拟机Hyper-V的功能&#xff0c;不太占资源&…...

SAP不同语言开发

文章目录 1 Please write English Nmae2 go to goto menu and translation3 Write your target language .4 Please input Chinese5 Summary 1 Please write English Nmae 2 go to goto menu and translation 3 Write your target language . 4 Please input Chinese 5 Summary…...

瑞_Java开发手册_(一)编程规约

文章目录 编程规约的意义&#xff08;一&#xff09;命名风格&#xff08;二&#xff09;常量定义&#xff08;三&#xff09;代码格式&#xff08;四&#xff09;OOP 规约&#xff08;五&#xff09;日期时间&#xff08;六&#xff09;集合处理&#xff08;七&#xff09;并发…...

【JVM】本地方法接口 Native Interface

一、JNI简介 JVM本地方法接口&#xff08;Java Native Interface&#xff0c;JNI&#xff09;是一种允许Java代码调用本地方法&#xff08;如C或C编写的方法&#xff09;的机制。这种技术通常用于实现高性能的计算密集型任务&#xff0c;或者与底层系统库进行交互。 二、JNI组…...

JS 本地存储 sessionStorage localStorage

本地存储 随着互联网的快速发展&#xff0c;基于网页的应用越来越普遍&#xff0c;同时也变的越来越复杂&#xff0c;为了满足各种各样的需求&#xff0c;会经常性在本地存储大量的数据&#xff0c;HTML5规范提出了相关解决方案。 本地存储特性 1、数据存储在用户浏览器中 2…...

K8S 存储卷

意义&#xff1a;存储卷----数据卷 容器内的目录和宿主机的目录进行挂载 容器在系统上的生命周期是短暂的&#xff0c;delete,k8s用控制器创建的pod&#xff0c;delete相当于重启&#xff0c;容器的状态也会回复到初始状态 一旦回到初始状态&#xff0c;所有的后天编辑的文件…...

一个SqlSugar实际案例

SqlGugar是一个非常好的数据库操作框架&#xff0c;今天用一个示例来分享如何使用。 新建一张课程表 结构如下&#xff1a; CREATE TABLE t_course (id int NOT NULL AUTO_INCREMENT COMMENT ID,title varchar(1024) NOT NULL COMMENT 课程标题,description text NOT NULL C…...

利用ngx_stream_return_module构建简易 TCP/UDP 响应网关

一、模块概述 ngx_stream_return_module 提供了一个极简的指令&#xff1a; return <value>;在收到客户端连接后&#xff0c;立即将 <value> 写回并关闭连接。<value> 支持内嵌文本和内置变量&#xff08;如 $time_iso8601、$remote_addr 等&#xff09;&a…...

将对透视变换后的图像使用Otsu进行阈值化,来分离黑色和白色像素。这句话中的Otsu是什么意思?

Otsu 是一种自动阈值化方法&#xff0c;用于将图像分割为前景和背景。它通过最小化图像的类内方差或等价地最大化类间方差来选择最佳阈值。这种方法特别适用于图像的二值化处理&#xff0c;能够自动确定一个阈值&#xff0c;将图像中的像素分为黑色和白色两类。 Otsu 方法的原…...

AI编程--插件对比分析:CodeRider、GitHub Copilot及其他

AI编程插件对比分析&#xff1a;CodeRider、GitHub Copilot及其他 随着人工智能技术的快速发展&#xff0c;AI编程插件已成为提升开发者生产力的重要工具。CodeRider和GitHub Copilot作为市场上的领先者&#xff0c;分别以其独特的特性和生态系统吸引了大量开发者。本文将从功…...

企业如何增强终端安全?

在数字化转型加速的今天&#xff0c;企业的业务运行越来越依赖于终端设备。从员工的笔记本电脑、智能手机&#xff0c;到工厂里的物联网设备、智能传感器&#xff0c;这些终端构成了企业与外部世界连接的 “神经末梢”。然而&#xff0c;随着远程办公的常态化和设备接入的爆炸式…...

为什么要创建 Vue 实例

核心原因:Vue 需要一个「控制中心」来驱动整个应用 你可以把 Vue 实例想象成你应用的**「大脑」或「引擎」。它负责协调模板、数据、逻辑和行为,将它们变成一个活的、可交互的应用**。没有这个实例,你的代码只是一堆静态的 HTML、JavaScript 变量和函数,无法「活」起来。 …...

tauri项目,如何在rust端读取电脑环境变量

如果想在前端通过调用来获取环境变量的值&#xff0c;可以通过标准的依赖&#xff1a; std::env::var(name).ok() 想在前端通过调用来获取&#xff0c;可以写一个command函数&#xff1a; #[tauri::command] pub fn get_env_var(name: String) -> Result<String, Stri…...

StarRocks 全面向量化执行引擎深度解析

StarRocks 全面向量化执行引擎深度解析 StarRocks 的向量化执行引擎是其高性能的核心设计&#xff0c;相比传统行式处理引擎&#xff08;如MySQL&#xff09;&#xff0c;性能可提升 5-10倍。以下是分层拆解&#xff1a; 1. 向量化 vs 传统行式处理 维度行式处理向量化处理数…...

AWS vs 阿里云:功能、服务与性能对比指南

在云计算领域&#xff0c;Amazon Web Services (AWS) 和阿里云 (Alibaba Cloud) 是全球领先的提供商&#xff0c;各自在功能范围、服务生态系统、性能表现和适用场景上具有独特优势。基于提供的引用[1]-[5]&#xff0c;我将从功能、服务和性能三个方面进行结构化对比分析&#…...

matlab实现DBR激光器计算

DBR激光器计算程序。非常值得参考的程序。DBR激光器程序 DBR计算/1.txt , 2056 DBR计算/4.asv , 22 DBR计算/4.txt , 32 DBR计算/GetDeviceEfficiency.asv , 2012 DBR计算/GetDeviceEfficiency.m , 2014 DBR计算/GetOneLayerArray.asv , 837 DBR计算/GetOneLayerArray.m , 836…...

【立体匹配】:双目立体匹配SGBM:(1)运行

注&#xff1a;这是一个专题&#xff0c;我会一步步介绍SGBM的实现&#xff0c;按照我的使用和优化过程逐步改善算法&#xff0c;附带实现方法 系列文章【立体匹配】&#xff1a;双目立体匹配SGBM&#xff1a;&#xff08;1&#xff09;运行 【立体匹配】&#xff1a;双目立体匹…...