当前位置: 首页 > 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…...

React hook之useRef

React useRef 详解 useRef 是 React 提供的一个 Hook&#xff0c;用于在函数组件中创建可变的引用对象。它在 React 开发中有多种重要用途&#xff0c;下面我将全面详细地介绍它的特性和用法。 基本概念 1. 创建 ref const refContainer useRef(initialValue);initialValu…...

【WiFi帧结构】

文章目录 帧结构MAC头部管理帧 帧结构 Wi-Fi的帧分为三部分组成&#xff1a;MAC头部frame bodyFCS&#xff0c;其中MAC是固定格式的&#xff0c;frame body是可变长度。 MAC头部有frame control&#xff0c;duration&#xff0c;address1&#xff0c;address2&#xff0c;addre…...

【碎碎念】宝可梦 Mesh GO : 基于MESH网络的口袋妖怪 宝可梦GO游戏自组网系统

目录 游戏说明《宝可梦 Mesh GO》 —— 局域宝可梦探索Pokmon GO 类游戏核心理念应用场景Mesh 特性 宝可梦玩法融合设计游戏构想要素1. 地图探索&#xff08;基于物理空间 广播范围&#xff09;2. 野生宝可梦生成与广播3. 对战系统4. 道具与通信5. 延伸玩法 安全性设计 技术选…...

算法岗面试经验分享-大模型篇

文章目录 A 基础语言模型A.1 TransformerA.2 Bert B 大语言模型结构B.1 GPTB.2 LLamaB.3 ChatGLMB.4 Qwen C 大语言模型微调C.1 Fine-tuningC.2 Adapter-tuningC.3 Prefix-tuningC.4 P-tuningC.5 LoRA A 基础语言模型 A.1 Transformer &#xff08;1&#xff09;资源 论文&a…...

C++.OpenGL (20/64)混合(Blending)

混合(Blending) 透明效果核心原理 #mermaid-svg-SWG0UzVfJms7Sm3e {font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-svg-SWG0UzVfJms7Sm3e .error-icon{fill:#552222;}#mermaid-svg-SWG0UzVfJms7Sm3e .error-text{fill…...

Go语言多线程问题

打印零与奇偶数&#xff08;leetcode 1116&#xff09; 方法1&#xff1a;使用互斥锁和条件变量 package mainimport ("fmt""sync" )type ZeroEvenOdd struct {n intzeroMutex sync.MutexevenMutex sync.MutexoddMutex sync.Mutexcurrent int…...

【Linux系统】Linux环境变量:系统配置的隐形指挥官

。# Linux系列 文章目录 前言一、环境变量的概念二、常见的环境变量三、环境变量特点及其相关指令3.1 环境变量的全局性3.2、环境变量的生命周期 四、环境变量的组织方式五、C语言对环境变量的操作5.1 设置环境变量&#xff1a;setenv5.2 删除环境变量:unsetenv5.3 遍历所有环境…...

tomcat指定使用的jdk版本

说明 有时候需要对tomcat配置指定的jdk版本号&#xff0c;此时&#xff0c;我们可以通过以下方式进行配置 设置方式 找到tomcat的bin目录中的setclasspath.bat。如果是linux系统则是setclasspath.sh set JAVA_HOMEC:\Program Files\Java\jdk8 set JRE_HOMEC:\Program Files…...

Oracle11g安装包

Oracle 11g安装包 适用于windows系统&#xff0c;64位 下载路径 oracle 11g 安装包...

学习一下用鸿蒙​​DevEco Studio HarmonyOS5实现百度地图

在鸿蒙&#xff08;HarmonyOS5&#xff09;中集成百度地图&#xff0c;可以通过以下步骤和技术方案实现。结合鸿蒙的分布式能力和百度地图的API&#xff0c;可以构建跨设备的定位、导航和地图展示功能。 ​​1. 鸿蒙环境准备​​ ​​开发工具​​&#xff1a;下载安装 ​​De…...