日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

日志服务数据加工最佳实践: 从其他logstore拉取数据做富化

發(fā)布時(shí)間:2024/8/23 编程问答 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 日志服务数据加工最佳实践: 从其他logstore拉取数据做富化 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

概述

使用全局富化函數(shù)做富化時(shí), 需要傳遞一個(gè)字典或者表格結(jié)構(gòu)做富化. 參考構(gòu)建字典與表格做數(shù)據(jù)富化的各種途徑比較.?
本篇介紹從使用資源函數(shù)res_log_logstore_pull從其他logstore拉取數(shù)據(jù)的做富化的詳細(xì)實(shí)踐.關(guān)于res_log_logstore_pull的參數(shù)說明, 參考這里. 該語法目前支持兩種模式去logstore拉取數(shù)據(jù),一種是拉取指定時(shí)間間隔內(nèi)的logstore 的數(shù)據(jù)內(nèi)容,另外一種是不設(shè)置結(jié)束時(shí)間,持續(xù)的拉取目標(biāo)logstore內(nèi)容

背景

這里我們有兩個(gè)logstore,一個(gè)是存儲(chǔ)個(gè)人信息的source_logstore,一個(gè)是酒店存儲(chǔ)客人入住信息的target_logstore ,我們現(xiàn)在將酒店的入住信息拿來做富化。
注意: 這里采用pull_log接口拉取數(shù)據(jù), 富化的logstore并不依賴索引.

個(gè)人信息 source_logstore

topic:xxx city:xxx cid:12345 name:makitopic:xxx city:xxx cid:12346 name:vickytopic:xxx city:xxx cid:12347 name:mary

酒店入住信息logstore

time:1567038284 status:check in cid:12345 name:maki room_number:1111time:1567038284 status:check in cid:12346 name:vicky room_number:2222time:1567038500 status:check in cid:12347 name:mary room_number:3333time:1567038500 status:leave cid:12345 name:maki room_number:1111

基本語法

res_log_logstore_pull(endpoint,ak_id,ak_secret,project,logstore,fields,from_time=None,to_time=None,fetch_include_data=None,fetch_exclude_data=None,primary_keys=None,delete_data=None,refresh_interval_max=60,fetch_interval=2):

具體的參數(shù)說明請(qǐng)參考res_log_logstore_pull,需要注意的地方是,res_log_logstore_pull 是一個(gè)單獨(dú)的語法,只負(fù)責(zé)從目標(biāo)logstore 拉取數(shù)據(jù)下來,本身自己并沒有做任何富化的操作,所以請(qǐng)不要單獨(dú)使用res_log_logstore_pull語法,結(jié)合e_table_map和e_search_table_map語句一起使用才是有意義的,本篇也會(huì)結(jié)合e_table_map和e_search_map_table的使用給出一些例子進(jìn)行演示。

場(chǎng)景1:?獲取指定時(shí)間內(nèi)所有的數(shù)據(jù)

注意: 這里的時(shí)間是日志獲取時(shí)間.

DSL編排語法

res_log_logstore_pull(..., ["cid","name","room_number"],from_time=1567038284,to_time=1567038500)

獲取到的數(shù)據(jù)

#這里我們的語法中 field 填入了 cid,name,room_number 三個(gè)字段,,并且指定了時(shí)間范圍,將會(huì)獲取這個(gè)時(shí)間范圍內(nèi)的logstore的所有數(shù)據(jù)的這三個(gè)字段的值cid:12345 name:maki room_number:1111cid:12346 name:vicky room_number:2222cid:12347 name:mary room_number:3333cid:12345 name:maki room_number:1111

場(chǎng)景2: 設(shè)置黑白名單參數(shù)來過濾拉取的數(shù)據(jù)

1.DSL 編排語法(只設(shè)置白名單)

# 設(shè)置白名單,只有 room_number 值等于 1111的的數(shù)據(jù)會(huì)被拉去下來 res_log_logstore_pull(..., ["cid","name","room_number","status"],from_time=1567038284,to_time=1567038500,fetch_include_data="room_number:1111")

獲取到的數(shù)據(jù)

# 設(shè)置了 ferch_include_data 白名單,只有包含 room_numver:1111的數(shù)據(jù)會(huì)被拉去下來,其他數(shù)據(jù)不會(huì)被拉取。status: check in cid:12345 name:maki room_number:1111status:leave cid:12345 name:maki room_number:1111

2.DSL 編排語法(只設(shè)置黑名單)

res_log_logstore_pull(..., ["cid","name","room_number","status"],from_time=1567038284,to_time=1567038500,fetch_exclude_data="room_number:1111")

獲取到的數(shù)據(jù)

# 設(shè)置黑名單 fetch_exclude_data 當(dāng)數(shù)據(jù)包含 room_number:1111的時(shí)候丟棄這條數(shù)據(jù)。 status:check in cid:12346 name:vicky room_number:2222status:check in cid:12347 name:mary room_number:3333

3.DSL編排語法(同時(shí)設(shè)置黑白名單)

res_log_logstore_pull(..., ["cid","name","room_number","status"],from_time=1567038284,to_time=1567038500,fetch_exclude_data="status:leave",fetch_include_data="status:check in")

獲取到的數(shù)據(jù)

# 黑白名單同時(shí)存在的情況下,優(yōu)先進(jìn)行黑名單數(shù)據(jù)的匹配,這里我們填入的是 status:leave的值,當(dāng)數(shù)據(jù)包含status:leave的值時(shí)候,數(shù)據(jù)會(huì)被直接丟棄,而后匹配白名單,白名單我們填入的是 status:check in 當(dāng)數(shù)據(jù)包含 status: check in 的值時(shí)候,該數(shù)據(jù)才會(huì)被拉取下來. status:check in cid:12345 name:maki room_number:1111status:check in cid:12346 name:vicky room_number:2222status:check in cid:12347 name:mary room_number:3333

場(chǎng)景3: 開通持續(xù)拉取目標(biāo)logstore 數(shù)據(jù)

DSL編排語法

如果目標(biāo)logstore 的數(shù)據(jù)是持續(xù)寫入,我們需要持續(xù)的去拉取時(shí)候,設(shè)置 to_time 參數(shù)為None 就可以,同時(shí)可以設(shè)置fetch_interval 設(shè)置拉取的時(shí)間間隔,和refresh_interval_max 當(dāng)拉取遇到錯(cuò)誤的時(shí)候退火重試的最大時(shí)間間隔

res_log_logstore_pull(..., ["cid","name","room_number","status"],from_time=1567038284,to_time=None,fetch_interval=15,refresh_interval_max=60) # 需要注意的是,在持續(xù)拉取的過程中,如果遇到錯(cuò)誤,服務(wù)器會(huì)一直退火重試,直到成功為止,不會(huì)停止數(shù)據(jù)加工進(jìn)程。

場(chǎng)景4: 開啟主鍵維護(hù)拉取的目標(biāo)logstore數(shù)據(jù)(暫時(shí)不推薦)

注意事項(xiàng)

目前該功能僅限使用所有數(shù)據(jù)存儲(chǔ)在logstore的同一個(gè)shard中,所以暫時(shí)不推薦使用該功能。

背景

以我們的個(gè)人信息logstore 和 酒店信息logstore的數(shù)據(jù)進(jìn)行舉例,因?yàn)閘ogstore和數(shù)據(jù)庫不同,logstore中的數(shù)據(jù)只能寫入,無法刪除,所以有的時(shí)候我們希望匹配的時(shí)候?qū)⒁呀?jīng)刪除的數(shù)據(jù)不要進(jìn)行匹配,這時(shí)候就需要開啟主鍵維護(hù)功能。

需求演示

現(xiàn)在我們想拉取酒店信息logstore中,所有入住還沒有離開的客人信息,當(dāng)status=leave的時(shí)候,表示客人已經(jīng)離開酒店,所以不需要將該信息進(jìn)行拉取。

DSL編排語法

res_log_logstore_pull(..., ["cid","name","room_number","status","time"],from_time=1567038284,to_time=None,primary_keys="cid",delete_data="status:leave")

得到的數(shù)據(jù)

## 可以看到 name為maki 的客人的最后更新status為leave ,已經(jīng)離開酒店,所以并沒有將 maki的數(shù)據(jù)拉取下來, time:1567038284 status:check in cid:12346 name:vicky room_number:2222time:1567038500 status:check in cid:12347 name:mary room_number:3333

注意

需要注意的是 primary_keys 目前只支持設(shè)置單字符串,這個(gè)需要設(shè)置logstore數(shù)據(jù)中 值為唯一的字段,比如樣例中的cid , 類似數(shù)據(jù)庫的唯一主鍵,并且當(dāng)設(shè)置primary_keys的時(shí)候,delete_data 也必須不為 None,這樣才有意義。


原文鏈接
本文為云棲社區(qū)原創(chuàng)內(nèi)容,未經(jīng)允許不得轉(zhuǎn)載。

總結(jié)

以上是生活随笔為你收集整理的日志服务数据加工最佳实践: 从其他logstore拉取数据做富化的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。