亚欧色一区w666天堂,色情一区二区三区免费看,少妇特黄A片一区二区三区,亚洲人成网站999久久久综合,国产av熟女一区二区三区

  • 發布文章
  • 消息中心
點贊
收藏
評論
分享
原創

Prometheus自定義遠程存儲實現

2023-05-29 06:05:55
155
0

前沿

Prometheus 是一種開源的監控系統,用于記錄和查詢系統的各種指標。Prometheus 可以通過其自身的存儲方式存儲指標數據,也可以通過遠程存儲實現長期存儲。

Prometheus 遠程存儲允許將指標數據存儲到第三方存儲系統中,例如 Amazon S3、Google Cloud Storage 或 OpenStack Swift。這種存儲方式可以用于長期存儲,以便進行更長時間范圍內的數據分析。整體架構圖如下:

Prometheus接口規范

數據寫入

Prometheus 遠程寫入數據的格式是 protobuf 格式。Prometheus server 將內存數據庫中的指標數據按照時間序列進行組織,并將其編碼為 protobuf 格式。

protobuf 格式是一種二進制格式,它可以將復雜的數據結構進行高效的編碼和解碼。在 Prometheus 中,protobuf 格式被用來表示時間序列和標簽。時間序列是一組帶有相同標簽的數據點,其中標簽是鍵值對,用于區分不同的時間序列。

Prometheus server 會將時間序列和標簽編碼為 protobuf 格式,并通過 HTTP 協議發送到遠程存儲系統中。遠程存儲系統接收到請求后,會將請求中的數據解碼,并將其存儲在其自身的存儲系統中。在查詢時,Prometheus server 會向遠程存儲系統發送 HTTP GET 請求,并解碼從遠程存儲系統返回的 protobuf 編碼的數據。

總之,Prometheus 遠程寫入數據的格式是 protobuf 格式,它可以將復雜的數據結構進行高效的編碼和解碼,并實現了將指標數據存儲到第三方存儲系統中的功能。

WriteRequest數據格式

type WriteRequest struct {
Timeseries []TimeSeries `protobuf:"bytes,1,rep,name=timeseries,proto3" json:"timeseries"`
Metadata []MetricMetadata `protobuf:"bytes,3,rep,name=metadata,proto3" json:"metadata"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}

TimeSeries數據格式
type TimeSeries struct {
// For a timeseries to be valid, and for the samples and exemplars
// to be ingested by the remote system properly, the labels field is required.
Labels []Label `protobuf:"bytes,1,rep,name=labels,proto3" json:"labels"`
Samples []Sample `protobuf:"bytes,2,rep,name=samples,proto3" json:"samples"`
Exemplars []Exemplar `protobuf:"bytes,3,rep,name=exemplars,proto3" json:"exemplars"`
Histograms []Histogram `protobuf:"bytes,4,rep,name=histograms,proto3" json:"histograms"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}

數據讀取

遠程數據讀取是指從Prometheus服務器連接到遠程目標,并直接讀取其指標數據。當用戶發起查詢請求后,Promthues將向remote_read中配置的URL發起查詢請求(matchers,ranges),Adaptor根據請求條件從第三方存儲服務中獲取響應的數據。同時將數據轉換為Promthues的原始樣本數據返回給Prometheus Server。

主要的數據結構如下

type ReadRequest struct {
Queries []*Query `protobuf:"bytes,1,rep,name=queries,proto3" json:"queries,omitempty"`
// accepted_response_types allows negotiating the content type of the response.
//
// Response types are taken from the list in the FIFO order. If no response type in `accepted_response_types` is
// implemented by server, error is returned.
// For request that do not contain `accepted_response_types` field the SAMPLES response type will be used.
AcceptedResponseTypes []ReadRequest_ResponseType `protobuf:"varint,2,rep,packed,name=accepted_response_types,json=acceptedResponseTypes,proto3,enum=prometheus.ReadRequest_ResponseType" json:"accepted_response_types,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
type Query struct {
StartTimestampMs int64 `protobuf:"varint,1,opt,name=start_timestamp_ms,json=startTimestampMs,proto3" json:"start_timestamp_ms,omitempty"`
EndTimestampMs int64 `protobuf:"varint,2,opt,name=end_timestamp_ms,json=endTimestampMs,proto3" json:"end_timestamp_ms,omitempty"`
Matchers []*LabelMatcher `protobuf:"bytes,3,rep,name=matchers,proto3" json:"matchers,omitempty"`
Hints *ReadHints `protobuf:"bytes,4,opt,name=hints,proto3" json:"hints,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
type ReadHints struct {
StepMs int64 `protobuf:"varint,1,opt,name=step_ms,json=stepMs,proto3" json:"step_ms,omitempty"`
Func string `protobuf:"bytes,2,opt,name=func,proto3" json:"func,omitempty"`
StartMs int64 `protobuf:"varint,3,opt,name=start_ms,json=startMs,proto3" json:"start_ms,omitempty"`
EndMs int64 `protobuf:"varint,4,opt,name=end_ms,json=endMs,proto3" json:"end_ms,omitempty"`
Grouping []string `protobuf:"bytes,5,rep,name=grouping,proto3" json:"grouping,omitempty"`
By bool `protobuf:"varint,6,opt,name=by,proto3" json:"by,omitempty"`
RangeMs int64 `protobuf:"varint,7,opt,name=range_ms,json=rangeMs,proto3" json:"range_ms,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
type ReadResponse struct {
// In same order as the request's queries.
Results []*QueryResult `protobuf:"bytes,1,rep,name=results,proto3" json:"results,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
type QueryResult struct {
// Samples within a time series must be ordered by time.
Timeseries []*TimeSeries `protobuf:"bytes,1,rep,name=timeseries,proto3" json:"timeseries,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}

通過ReadRequest 我們可以知道請求的起始時間,labelMathcer,rangeMs,group等信息,拿到這些信息之后,我們就可以根據遠程存儲的特點,讀取遠程存儲的數據,返回ReadResponse 給Prometheus。

總結

從上述分析看,實現Prometheus遠程存儲適配工作量并不大。目前Prometheus社區也提供了部分對于第三方數據庫的Remote Storage支持:

VictoriaMetrics、Thanos也可以用來作為Prometheus的遠程存儲。這些解決方案允許將Prometheus的指標數據存儲在遠程位置,以實現高可用性、擴展性和持久性。選擇適合的遠程存儲方案取決于你的需求和環境。

 

 

 

0條評論
0 / 1000
齊****軍
14文章數
0粉絲數
齊****軍
14 文章 | 0 粉絲
齊****軍
14文章數
0粉絲數
齊****軍
14 文章 | 0 粉絲
原創

Prometheus自定義遠程存儲實現

2023-05-29 06:05:55
155
0

前沿

Prometheus 是一種開源的監控系統,用于記錄和查詢系統的各種指標。Prometheus 可以通過其自身的存儲方式存儲指標數據,也可以通過遠程存儲實現長期存儲。

Prometheus 遠程存儲允許將指標數據存儲到第三方存儲系統中,例如 Amazon S3、Google Cloud Storage 或 OpenStack Swift。這種存儲方式可以用于長期存儲,以便進行更長時間范圍內的數據分析。整體架構圖如下:

Prometheus接口規范

數據寫入

Prometheus 遠程寫入數據的格式是 protobuf 格式。Prometheus server 將內存數據庫中的指標數據按照時間序列進行組織,并將其編碼為 protobuf 格式。

protobuf 格式是一種二進制格式,它可以將復雜的數據結構進行高效的編碼和解碼。在 Prometheus 中,protobuf 格式被用來表示時間序列和標簽。時間序列是一組帶有相同標簽的數據點,其中標簽是鍵值對,用于區分不同的時間序列。

Prometheus server 會將時間序列和標簽編碼為 protobuf 格式,并通過 HTTP 協議發送到遠程存儲系統中。遠程存儲系統接收到請求后,會將請求中的數據解碼,并將其存儲在其自身的存儲系統中。在查詢時,Prometheus server 會向遠程存儲系統發送 HTTP GET 請求,并解碼從遠程存儲系統返回的 protobuf 編碼的數據。

總之,Prometheus 遠程寫入數據的格式是 protobuf 格式,它可以將復雜的數據結構進行高效的編碼和解碼,并實現了將指標數據存儲到第三方存儲系統中的功能。

WriteRequest數據格式

type WriteRequest struct {
Timeseries []TimeSeries `protobuf:"bytes,1,rep,name=timeseries,proto3" json:"timeseries"`
Metadata []MetricMetadata `protobuf:"bytes,3,rep,name=metadata,proto3" json:"metadata"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}

TimeSeries數據格式
type TimeSeries struct {
// For a timeseries to be valid, and for the samples and exemplars
// to be ingested by the remote system properly, the labels field is required.
Labels []Label `protobuf:"bytes,1,rep,name=labels,proto3" json:"labels"`
Samples []Sample `protobuf:"bytes,2,rep,name=samples,proto3" json:"samples"`
Exemplars []Exemplar `protobuf:"bytes,3,rep,name=exemplars,proto3" json:"exemplars"`
Histograms []Histogram `protobuf:"bytes,4,rep,name=histograms,proto3" json:"histograms"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}

數據讀取

遠程數據讀取是指從Prometheus服務器連接到遠程目標,并直接讀取其指標數據。當用戶發起查詢請求后,Promthues將向remote_read中配置的URL發起查詢請求(matchers,ranges),Adaptor根據請求條件從第三方存儲服務中獲取響應的數據。同時將數據轉換為Promthues的原始樣本數據返回給Prometheus Server。

主要的數據結構如下

type ReadRequest struct {
Queries []*Query `protobuf:"bytes,1,rep,name=queries,proto3" json:"queries,omitempty"`
// accepted_response_types allows negotiating the content type of the response.
//
// Response types are taken from the list in the FIFO order. If no response type in `accepted_response_types` is
// implemented by server, error is returned.
// For request that do not contain `accepted_response_types` field the SAMPLES response type will be used.
AcceptedResponseTypes []ReadRequest_ResponseType `protobuf:"varint,2,rep,packed,name=accepted_response_types,json=acceptedResponseTypes,proto3,enum=prometheus.ReadRequest_ResponseType" json:"accepted_response_types,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
type Query struct {
StartTimestampMs int64 `protobuf:"varint,1,opt,name=start_timestamp_ms,json=startTimestampMs,proto3" json:"start_timestamp_ms,omitempty"`
EndTimestampMs int64 `protobuf:"varint,2,opt,name=end_timestamp_ms,json=endTimestampMs,proto3" json:"end_timestamp_ms,omitempty"`
Matchers []*LabelMatcher `protobuf:"bytes,3,rep,name=matchers,proto3" json:"matchers,omitempty"`
Hints *ReadHints `protobuf:"bytes,4,opt,name=hints,proto3" json:"hints,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
type ReadHints struct {
StepMs int64 `protobuf:"varint,1,opt,name=step_ms,json=stepMs,proto3" json:"step_ms,omitempty"`
Func string `protobuf:"bytes,2,opt,name=func,proto3" json:"func,omitempty"`
StartMs int64 `protobuf:"varint,3,opt,name=start_ms,json=startMs,proto3" json:"start_ms,omitempty"`
EndMs int64 `protobuf:"varint,4,opt,name=end_ms,json=endMs,proto3" json:"end_ms,omitempty"`
Grouping []string `protobuf:"bytes,5,rep,name=grouping,proto3" json:"grouping,omitempty"`
By bool `protobuf:"varint,6,opt,name=by,proto3" json:"by,omitempty"`
RangeMs int64 `protobuf:"varint,7,opt,name=range_ms,json=rangeMs,proto3" json:"range_ms,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
type ReadResponse struct {
// In same order as the request's queries.
Results []*QueryResult `protobuf:"bytes,1,rep,name=results,proto3" json:"results,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
type QueryResult struct {
// Samples within a time series must be ordered by time.
Timeseries []*TimeSeries `protobuf:"bytes,1,rep,name=timeseries,proto3" json:"timeseries,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}

通過ReadRequest 我們可以知道請求的起始時間,labelMathcer,rangeMs,group等信息,拿到這些信息之后,我們就可以根據遠程存儲的特點,讀取遠程存儲的數據,返回ReadResponse 給Prometheus。

總結

從上述分析看,實現Prometheus遠程存儲適配工作量并不大。目前Prometheus社區也提供了部分對于第三方數據庫的Remote Storage支持:

VictoriaMetrics、Thanos也可以用來作為Prometheus的遠程存儲。這些解決方案允許將Prometheus的指標數據存儲在遠程位置,以實現高可用性、擴展性和持久性。選擇適合的遠程存儲方案取決于你的需求和環境。

 

 

 

文章來自個人專欄
文章 | 訂閱
0條評論
0 / 1000
請輸入你的評論
1
1