Splunk使用測試報告
一、技術組件及原理
1. Indexer 將本地或遠程日誌資料做索引。
工作機制:
可以對具有時間軸的任何格式的日誌資料做索引。這個索引動作是基於時間戳記將資料打亂後放入events中,每個events包含時間戳記、host、source、source type屬性。一般一行日誌就是一個event,如果是xml logs,可能被分解成多個events.當使用者搜尋時,這些events就被splunk搜尋到返回給使用者.
Events:A single piece of data in Splunk, similar to a record in a log file or other data input. When Splunk eats data, it breaks the data up into individual pieces and gives each piece a timestamp, host, source, and source type. Often, a single event corresponds nicely to a single line in your inputs, but some inputs have multiline events (for example, XML logs) and some inputs actually have multiple events on a single line. When you run a search, events are what you get back.
Event processing(事件處理):
包含2個階段:解析及索引。進入splunk的資料會作為一個塊(一般10k)放入解析管道中。解析過程中,這些塊會被打亂。解析過程包括下面一些動作:
· Extracting a set of default fields for each event, including host, source, and sourcetype.
· Configuring character set encoding.
· Identifying line termination using linebreaking rules. While many events are short and only take up a line or two, others can be long.
· Identifying timestamps or creating them if they don't exist. At the same time that it processes timestamps, Splunk identifies event boundaries.
· Splunk can be set up to mask sensitive event data (such as credit card or social security numbers) at this stage. It can also be configured to apply custom metadata to incoming events.
在索引管道中,還有其他一些操作:
· Breaking all events into segments that can then be searched upon. You can determine the level of segmentation, which affects indexing and searching speed, search capability, and efficiency of disk compression.
· Building the index data structures.
· Writing the raw data and index files to disk, where post-indexing compression occurs.
只是簡單的描述了重要的流程。Parsing管道包含:parsing, merging, and typing 這個三個管道。
Event data:索引日誌資料後得到的索引資料
Event:通常是日誌資料的一條記錄
索引:索引包含2種類型的資料:
· The raw data in compressed form ("rawdata")
· Indexes that point to the raw data ("index files")
這些資料由目錄來存放,目錄被稱作:bucket,這些目錄按照時間來存放,這種方式能更好支援splunk對olddata的處理。
· A Splunk "index" contains compressed raw data and associated indexes.
· A Splunk index resides across many age-designated index directories.
· An index directory is a bucket.
這些bucket按照時間長久來滾動。層級有:
· hot
· warm
· cold
· frozen
As buckets age, they "roll" from one stage to the next. Newly indexed data goes into a hot bucket, which is a bucket that's both searchable and actively being written to. After the hot bucket reaches a certain size, it becomes a warm bucket, and a new hot bucket is created. Warm buckets are searchable, but are not actively written to. There are many warm buckets.
Once Splunk has created some maximum number of warm buckets, it begins to roll the warm buckets to cold based on their age. Always, the oldest warm bucket rolls to cold. Buckets continue to roll to cold as they age in this manner. After a set period of time, cold buckets roll to frozen, at which point they are either archived or deleted. By editing attributes in indexes.conf, you can specify the bucket aging policy, which determines when a bucket moves from one stage to the next.
Bucket stage |
Description |
Searchable? |
Hot |
Contains newly indexed data. Open for writing. One or more hot buckets for each index. |
Yes. |
Warm |
Data rolled from hot. There are many warm buckets. |
Yes. |
Cold |
Data rolled from warm. There are many cold buckets. |
Yes. |
Frozen |
Data rolled from cold. Splunk deletes frozen data by default, but you can also archive it. |
No. |
這些bucket按照stage可以被稱為 db。如hotdb,warmdb...
Db下又可以分區。每個bucket size都可以配置.
Index詳細目錄結果參見:
http://docs.splunk.com/Documentation/Splunk/4.3/Admin/HowSplunkstoresindexes
2. forwarder
部署在終端伺服器,負責將日誌資料轉寄到indexer。而且也可以轉到其他splunkserver或非splunkserver。有2種類型:
· Universal forwarders. These have a very light footprint and forward only unparsed data.
· Heavy forwarders. These have a larger footprint but can parse, and even index, data before forwarding it.
也可以是三種。詳見
http://docs.splunk.com/Documentation/Splunk/4.3/Deploy/Typesofforwarders
接收者一般是indexer.可以接收來自一個或多個forwarder的資料.接收者也可能是其他的forwarder.類似scribe. 不同的是 對資料有可能做解析和索引.
這種結構對資料聯合、負載平衡、資料路由提供了基礎支援。詳見:http://docs.splunk.com/Documentation/Splunk/4.3/Deploy/Forwarderdeploymenttopologies
3. Search head
當在進行分布式搜尋時,就會用到這個。比如有非常大量的資料,而且有很多使用者並發搜尋這些資料,這時在不同的indexer上做索引載入,就會有利於在不同伺服器上完成搜尋查詢,達到分流減輕負載的效果。這些將搜尋查詢請求分散到不同的indexers上的組件就是search head.
詳細請見
http://docs.splunk.com/Documentation/Splunk/4.3/Deploy/Whatisdistributedsearch
幾個圖:
This diagram shows a simple distributed search scenario for horizontal scaling, with one search head searching across three peers:
In this diagram showing a distributed search scenario for access control, a "security" department search head has visibility into all the indexing search peers. Each search peer also has the ability to search its own data. In addition, the department A search peer has access to both its data and the data of department B:
Finally, this diagram shows the use of load balancing and distributed search to provide high availability access to data:
4.Deployment Server
中心組態管理員 。每個splunk執行個體都可以作為一個deployment server.
The deployment sever handles configuration and content updates to existing Splunk installations. You cannot use it for initial or upgrade installations of Splunk components
Splunk instances that are remotely configured by deployment servers are called deployment clients. A Splunk instance can be both a deployment server and client at the same time.
術語:
Term |
Meaning |
deployment server |
A Splunk instance that acts as a centralized configuration manager. It pushes configuration updates to other Splunk instances. |
deployment client |
A remotely configured Splunk instance. It receives updates from the deployment server. |
server class |
A deployment configuration category shared by a group of deployment clients. A deployment client can belong to multiple server classes. |
deployment app |
A unit of content deployed to one or more members of a server class or classes. |
multi-tenant environment |
A deployment environment involving multiple deployment servers. |
二、splunk重要功能
1 資料匯入:支援使用資料類型來匯入檔案、目錄、或者apache日誌等等,也可以匯入其他檔案,並使用正則定義時間戳記格式。同時支援udp、 tcp或自訂指令碼收集資料。
2 索引庫:
支援建立索引庫,預設使用預設庫結構:
主目錄:$SPLUNK_DB/INDEX_NAME/db
Colddb:$SPLUNK_DB/INDEX_NAME/colddb
Thawed DB路徑(解凍資料):$SPLUNK_DB/INDEX_NAME/thaweddb
總量有上限設定
對索引庫有統計(總資料庫大小、比數、首筆及末筆時間、所屬應用)
3 轉寄接收
有管理介面配置轉寄與接收(即上文指的forwarder及indexer),通過ip:連接埠執行
4 支援分布式搜尋:需要提供節點的主機ip:port,管理使用者的使用者名稱、密碼使splunk可以通過遠程搜尋驗證
5 支援搜尋方塊方式中的任意搜尋,直接搜尋應用的日誌資料,並支援互動式搜尋(通過滑鼠反白日誌的一些詞語,就會自動加入到搜尋條件中)
6 支援欄位搜尋。預設提供了host、source、sourcetype。可以自訂添加。在搜尋網頁面中也可以隨時添加顯示欄位。這個地方為啥不是在使用者上傳時指定呢。
7 支援搜尋時按時間軸顯示,時間軸顯示搜尋命中的頻率高低。並可調整時間軸做進一步搜尋。
8 搜尋支援運算 支援 http代碼等,使用非常方便。做的很細緻
9 提供知識庫,支援使用者添加eventtype、欄位、標籤等
10 支援搜尋排程,計劃搜尋。
11 支援警示通知
12 結果展現多樣,不僅支援顯示來源資料,同時支援欄位表格顯示,圖形顯示。功能設定人性化
13 支援動態建立儀錶盤等視圖、報表等,支援線上列印。
14 支援使用者入門指導,方便使用者熟悉系統
三、優缺點
1 優點:
搜尋日誌內容變的非常方便;
支援分布式搜尋,擴充性、容錯、負載平衡能力強大
支援圖形化搜尋結果,支援報表
支援排程方式搜尋
支援警示通知
時間軸方式只管展現搜尋趨勢及結果
2 缺點
統計日誌資料方面是弱項
索引資料及搜尋資料存放到indexers中,indexer掛掉會遺失資料,倒是forwarder可以選擇在本地備份
看了官方技術體系,現在還不是很確定,如果是日誌產生量超大情況下,因為forwarder會轉寄到一個indexer或者多個,但是搜尋效能會不會顯著下降未可知,雖然他內部有search head分散到多個indexer中。