- Notifications
You must be signed in to change notification settings - Fork2
iamxvbaba/openobserve
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
本库是一个用于日志收集的 Go 语言组件库,支持异步和同步发送日志数据到指定的OpenObserve。该库提供了灵活的配置选项,包括基本认证、授权、请求超时、索引名称等。
goget-ugithub.com/iamxvbaba/openobserve
以下是一个简单的使用示例:
package mainimport ("context""github.com/iamxvbaba/openobserve""time")funcmain() {// 创建一个上下文ctx,cancel:=context.WithCancel(context.Background())deferfunc() {cancel()// 确保缓存区数据能发送完成time.Sleep(3*time.Second) }// 创建 OpenObLog 实例log:=openobserve.New(ctx,"http://localhost:5080",openobserve.WithFullSize(100),openobserve.WithRequestTimeout(time.Second*5),openobserve.WithIndexName("logs",true),openobserve.WithAuthorization("token"))// 异步发送日志数据log.Send(map[string]any{"_timestamp":time.Now().UnixMicro(),"name":"xuhui","message":"你好","log":"ip-10-2-56-221.us-east-2.compute.internal","i":i,})}
提供了以下配置选项:
WithBasicAuth
: 使用用户名和密码进行基本认证。WithAuthorization
: 使用 token 进行授权。WithFullSize
: 指定达到的数量时马上请求。WithWaitTime
: 每过指定时间发起请求。WithRequestTimeout
: 设置 HTTP 请求超时时间。WithIndexName
: 设置索引名称,并指定是否按天切割索引。WithCompress
: 对请求报文进行 gzip 压缩。
提供了以下方法:
SendSync
: 同步发送日志数据。Send
: 异步发送日志数据。
- 使用前请确保你的日志服务地址和认证信息已正确配置。
- 请根据实际需求设置合适的配置选项和参数。
About
openobserve log
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.