-
Notifications
You must be signed in to change notification settings - Fork 541
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18617 from zexi/automated-cherry-pick-of-#18545-u…
…pstream-master Automated cherry pick of #18545: feat(monitor,region,host,cloudmon): support VictoriaMetrics as TSDB backend
- Loading branch information
Showing
102 changed files
with
18,574 additions
and
436 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package monitor | ||
|
||
import "yunion.io/x/onecloud/pkg/apis" | ||
|
||
const ( | ||
DataSourceTypeInfluxdb = apis.SERVICE_TYPE_INFLUXDB | ||
DataSourceTypeVictoriaMetrics = apis.SERVICE_TYPE_VICTORIA_METRICS | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package tsdb // import "yunion.io/x/onecloud/pkg/cloudcommon/tsdb" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package tsdb | ||
|
||
import ( | ||
"math/rand" | ||
|
||
"yunion.io/x/pkg/errors" | ||
|
||
"yunion.io/x/onecloud/pkg/apis" | ||
"yunion.io/x/onecloud/pkg/mcclient" | ||
) | ||
|
||
type TSDBServiceSource struct { | ||
Type string | ||
URLs []string | ||
} | ||
|
||
func NewTSDBServiceSource(t string, urls []string) *TSDBServiceSource { | ||
return &TSDBServiceSource{ | ||
Type: t, | ||
URLs: urls, | ||
} | ||
} | ||
|
||
func GetDefaultServiceSource(s *mcclient.ClientSession, endpointType string) (*TSDBServiceSource, error) { | ||
errs := []error{} | ||
for _, sType := range []string{apis.SERVICE_TYPE_INFLUXDB, apis.SERVICE_TYPE_VICTORIA_METRICS} { | ||
urls, err := s.GetServiceURLs(sType, endpointType) | ||
if err != nil { | ||
errs = append(errs, errors.Wrapf(err, "get %s service type %q", endpointType, sType)) | ||
} | ||
if len(urls) != 0 { | ||
return NewTSDBServiceSource(sType, urls), nil | ||
} | ||
} | ||
return nil, errors.NewAggregate(errs) | ||
} | ||
|
||
func GetDefaultServiceSourceURLs(s *mcclient.ClientSession, endpointType string) ([]string, error) { | ||
src, err := GetDefaultServiceSource(s, endpointType) | ||
if err != nil { | ||
return nil, errors.Wrap(err, "GetDefaultServiceSource") | ||
} | ||
if len(src.URLs) == 0 { | ||
return nil, errors.Errorf("tsdb source %q URLs are empty", src.Type) | ||
} | ||
return src.URLs, nil | ||
} | ||
|
||
func GetDefaultServiceSourceURL(s *mcclient.ClientSession, endpointType string) (string, error) { | ||
urls, err := GetDefaultServiceSourceURLs(s, endpointType) | ||
if err != nil { | ||
return "", err | ||
} | ||
return urls[rand.Intn(len(urls))], nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.