@@ -716,6 +716,53 @@ func (s *LogStore) GetHistogramsV2(ghr *GetHistogramRequest) (*GetHistogramsResp
716
716
return & getHistogramsResponse , nil
717
717
}
718
718
719
+ func (s * LogStore ) GetHistogramsV3 (ghr * GetHistogramRequest ) (* GetHistogramsResponse , error ) {
720
+
721
+ h := map [string ]string {
722
+ "x-log-bodyrawsize" : "0" ,
723
+ "Accept" : "application/json" ,
724
+ "Content-Type" : "application/json" ,
725
+ }
726
+
727
+ reqBody , err := ghr .ToJsonBody ()
728
+ if err != nil {
729
+ return nil , err
730
+ }
731
+
732
+ uri := fmt .Sprintf ("/logstores/%s/histograms" , s .Name )
733
+ r , err := request (s .project , "POST" , uri , h , reqBody )
734
+ if err != nil {
735
+ return nil , NewClientError (err )
736
+ }
737
+ defer r .Body .Close ()
738
+ body , _ := ioutil .ReadAll (r .Body )
739
+ if r .StatusCode != http .StatusOK {
740
+ err := new (Error )
741
+ if jErr := json .Unmarshal (body , err ); jErr != nil {
742
+ return nil , NewBadResponseError (string (body ), r .Header , r .StatusCode )
743
+ }
744
+ return nil , err
745
+ }
746
+
747
+ histograms := []SingleHistogram {}
748
+ err = json .Unmarshal (body , & histograms )
749
+ if err != nil {
750
+ return nil , NewBadResponseError (string (body ), r .Header , r .StatusCode )
751
+ }
752
+
753
+ count , err := strconv .ParseInt (r .Header .Get (GetLogsCountHeader ), 10 , 64 )
754
+ if err != nil {
755
+ return nil , err
756
+ }
757
+ getHistogramsResponse := GetHistogramsResponse {
758
+ Progress : r .Header [ProgressHeader ][0 ],
759
+ Count : count ,
760
+ Histograms : histograms ,
761
+ }
762
+
763
+ return & getHistogramsResponse , nil
764
+ }
765
+
719
766
// GetLogLines query logs with [from, to) time range
720
767
func (s * LogStore ) GetLogLines (topic string , from int64 , to int64 , queryExp string ,
721
768
maxLineNum int64 , offset int64 , reverse bool ) (* GetLogLinesResponse , error ) {
0 commit comments