尝试给上报到elasticsearch的文档加_id
This commit is contained in:
parent
b76a23b9d1
commit
0bec1b219e
@ -186,9 +186,6 @@ func hashString(input string) string {
|
||||
func (cl *Candle) ToStruct(core *Core) error {
|
||||
// cl.Timestamp
|
||||
|
||||
str := cl.InstId + "." + cl.Period + "." + cl.Data[0].(string)
|
||||
cl.Id = hashString(str)
|
||||
|
||||
// 将字符串转换为 int64 类型的时间戳
|
||||
ts, err := strconv.ParseInt(cl.Data[0].(string), 10, 64)
|
||||
if err != nil {
|
||||
@ -287,11 +284,14 @@ func (core *Core) SaveUniKey(period string, keyName string, extt time.Duration,
|
||||
fmt.Println("refName exist: ", refName)
|
||||
return
|
||||
}
|
||||
|
||||
did := cl.InstId + cl.Period + cl.Data[0].(string)
|
||||
cl.ToStruct(core)
|
||||
cd, _ := json.Marshal(cl)
|
||||
wg := WriteLog{
|
||||
Content: cd,
|
||||
Tag: "sardine.log.candle." + cl.Period,
|
||||
Id: hashString(did),
|
||||
}
|
||||
err = wg.Process(core)
|
||||
if err != nil {
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
type WriteLog struct {
|
||||
Content []byte
|
||||
Tag string
|
||||
Id string
|
||||
}
|
||||
|
||||
func (wg *WriteLog) Process(cr *Core) error {
|
||||
@ -19,7 +20,7 @@ func (wg *WriteLog) Process(cr *Core) error {
|
||||
reqBody := bytes.NewBuffer(wg.Content)
|
||||
cr.Env = os.Getenv("GO_ENV")
|
||||
cr.FluentBitUrl = os.Getenv("TEXUS_FluentBitUrl")
|
||||
fullUrl := "http://" + cr.FluentBitUrl + "/" + wg.Tag
|
||||
fullUrl := "http://" + cr.FluentBitUrl + "/" + wg.Tag + "/_doc/" + wg.Id
|
||||
res, err := http.Post(fullUrl, "application/json", reqBody)
|
||||
|
||||
fmt.Println("requested, response:", fullUrl, string(wg.Content), res)
|
||||
|
Loading…
x
Reference in New Issue
Block a user