Skip to content

Commit

Permalink
Merge pull request #18617 from zexi/automated-cherry-pick-of-#18545-u…
Browse files Browse the repository at this point in the history
…pstream-master

Automated cherry pick of #18545: feat(monitor,region,host,cloudmon): support VictoriaMetrics as TSDB backend
  • Loading branch information
zexi authored Nov 10, 2023
2 parents f52e78a + 9a94144 commit ed05401
Show file tree
Hide file tree
Showing 102 changed files with 18,574 additions and 436 deletions.
1 change: 1 addition & 0 deletions cmd/climc/shell/misc/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ func init() {
apis.SERVICE_TYPE_OFFLINE_CLOUDMETA,
apis.SERVICE_TYPE_CLOUDMETA,
apis.SERVICE_TYPE_INFLUXDB,
apis.SERVICE_TYPE_VICTORIA_METRICS,
apis.SERVICE_TYPE_ETCD,
"torrent-tracker",
}) {
Expand Down
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ require (
github.com/gosuri/uitable v0.0.0-20160404203958-36ee7e946282
github.com/hako/durafmt v0.0.0-20180520121703-7b7ae1e72ead
github.com/hugozhu/godingtalk v1.0.6
github.com/influxdata/influxql v1.1.0
github.com/influxdata/promql/v2 v2.12.0
github.com/jaypipes/ghw v0.11.0
github.com/koding/websocketproxy v0.0.0-20181220232114-7ed82d81a28c
github.com/lestrrat-go/jwx v1.0.2
Expand Down Expand Up @@ -62,6 +64,7 @@ require (
github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74
github.com/vmihailenco/msgpack v4.0.4+incompatible
github.com/xuri/excelize/v2 v2.7.1
github.com/zexi/influxql-to-promql v0.0.5
go.etcd.io/etcd/api/v3 v3.5.0
go.etcd.io/etcd/client/v3 v3.5.0
golang.org/x/crypto v0.8.0
Expand Down Expand Up @@ -132,6 +135,7 @@ require (
github.com/boltdb/bolt v1.3.1 // indirect
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc // indirect
github.com/bradfitz/iter v0.0.0-20140124041915-454541ec3da2 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58 // indirect
github.com/coreos/go-semver v0.3.0 // indirect
Expand Down
11 changes: 11 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ github.com/LeeEirc/terminalparser v0.0.0-20220328021224-de16b7643ea4/go.mod h1:t
github.com/Microsoft/azure-vhd-utils v0.0.0-20181115010904-44cbada2ece3 h1:gImoAO1xAcC1oDlYmD/X7dggsodGf2DFJOVE5m0ssms=
github.com/Microsoft/azure-vhd-utils v0.0.0-20181115010904-44cbada2ece3/go.mod h1:u0H9gMieFLxkUy8RS0X8VbFWyPs2815qQAaitRbj6x0=
github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ=
github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409/go.mod h1:1pk82RBxDY/JZnPQrtqHlUFfCctgdorsd9M06fMynOM=
Expand Down Expand Up @@ -173,6 +175,8 @@ github.com/bradfitz/iter v0.0.0-20140124041915-454541ec3da2/go.mod h1:PyRFw1Lt2w
github.com/c-bata/go-prompt v0.2.4 h1:7pKUJ3CUgzdu1HJeWhNRkpVyY/NnlJhM/7d6YgHNOao=
github.com/c-bata/go-prompt v0.2.4/go.mod h1:PqlttLXp0E7bZcoDW+dmzyKqFbmQTFoNzGSuW/AQRmo=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
Expand Down Expand Up @@ -421,6 +425,10 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
github.com/imdario/mergo v0.3.6 h1:xTNEAn+kxVO7dTZGu0CegyqKZmoWFI0rF8UxjlB2d28=
github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
github.com/influxdata/influxql v1.1.0 h1:sPsaumLFRPMwR5QtD3Up54HXpNND8Eu7G1vQFmi3quQ=
github.com/influxdata/influxql v1.1.0/go.mod h1:KpVI7okXjK6PRi3Z5B+mtKZli+R1DnZgb3N+tzevNgo=
github.com/influxdata/promql/v2 v2.12.0 h1:kXn3p0D7zPw16rOtfDR+wo6aaiH8tSMfhPwONTxrlEc=
github.com/influxdata/promql/v2 v2.12.0/go.mod h1:fxOPu+DY0bqCTCECchSRtWfc+0X19ybifQhZoQNF5D8=
github.com/ipandtcp/godingtalk v0.0.0-20180410032244-ca3d6ac197fb/go.mod h1:3umLciE1jBnh2LgrL15R2zbEe+HVPRZXnlSjjb/dYiw=
github.com/jaypipes/ghw v0.11.0 h1:i0pKvAM7eZk0KvLm9vzpcpDKTRnfR6AQ5pFkPVnYJXU=
github.com/jaypipes/ghw v0.11.0/go.mod h1:jeJGbkRB2lL3/gxYzNYzEDETV1ZJ56OKr+CSeSEym+g=
Expand Down Expand Up @@ -599,6 +607,7 @@ github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:
github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M=
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
github.com/prometheus/common v0.6.0/go.mod h1:eBmuwkDJBwy6iBfxCBob6t6dR6ENT/y+J+Zk0j9GMYc=
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc=
github.com/prometheus/common v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4=
Expand Down Expand Up @@ -734,6 +743,8 @@ github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg=
github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
github.com/zexi/influxql-to-promql v0.0.5 h1:4gRTqrof31O2Ku443RoTh20AadJG4sXbREn8i892WQo=
github.com/zexi/influxql-to-promql v0.0.5/go.mod h1:a+S9SfEZ/aVyBM5abA7UCQmp7vD8Q9o+GfkQhk5mM58=
go.etcd.io/etcd/api/v3 v3.5.0 h1:GsV3S+OfZEOCNXdtNkBSR7kgLobAa/SO6tCxRa0GAYw=
go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs=
go.etcd.io/etcd/client/pkg/v3 v3.5.0 h1:2aQv6F436YnN7I4VbI8PPYrBhu+SmrTaADcf8Mi/6PU=
Expand Down
10 changes: 6 additions & 4 deletions pkg/apis/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ const (
SERVICE_TYPE_CLOUDMON = "cloudmon"
SERVICE_TYPE_VPCAGENT = "vpcagent"

SERVICE_TYPE_ETCD = "etcd"
SERVICE_TYPE_INFLUXDB = "influxdb"
SERVICE_TYPE_ETCD = "etcd"
SERVICE_TYPE_INFLUXDB = "influxdb"
SERVICE_TYPE_NTP = "ntp"
SERVICE_TYPE_VICTORIA_METRICS = "victoria-metrics"

SERVICE_TYPE_SCHEDULEDTASK = "scheduledtask"

Expand Down Expand Up @@ -101,9 +103,9 @@ var (
"apigateway",
"yunionapi",
"billing",
"etcd",
SERVICE_TYPE_ETCD,
"itsm",
"ntp",
SERVICE_TYPE_NTP,
}
)

Expand Down
7 changes: 3 additions & 4 deletions pkg/apis/monitor/alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,9 @@ type AlertCondition struct {
}

type AlertQuery struct {
Model MetricQuery `json:"model"`
DataSourceId string `json:"data_source_id"`
From string `json:"from"`
To string `json:"to"`
Model MetricQuery `json:"model"`
From string `json:"from"`
To string `json:"to"`
}

type AlertCreateInput struct {
Expand Down
8 changes: 8 additions & 0 deletions pkg/apis/monitor/datasource.go
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
)
4 changes: 0 additions & 4 deletions pkg/apis/monitor/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@

package monitor

const (
DataSourceTypeInfluxdb = "influxdb"
)

type DataSourceConfig struct {
Id string
Name string
Expand Down
11 changes: 6 additions & 5 deletions pkg/baremetal/cronjobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
api "yunion.io/x/onecloud/pkg/apis/compute"
o "yunion.io/x/onecloud/pkg/baremetal/options"
"yunion.io/x/onecloud/pkg/cloudcommon/consts"
"yunion.io/x/onecloud/pkg/cloudcommon/tsdb"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/auth"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/logger"
Expand Down Expand Up @@ -221,11 +222,11 @@ func (job *SSendMetricsJob) Name() string {

func (job *SSendMetricsJob) Do(ctx context.Context, now time.Time) error {
s := auth.GetAdminSession(ctx, consts.GetRegion())
urls, err := s.GetServiceURLs("influxdb", o.Options.SessionEndpointType)
src, err := tsdb.GetDefaultServiceSource(s, o.Options.SessionEndpointType)
if err != nil {
return errors.Wrap(err, "s.GetServiceURLs")
return errors.Wrap(err, "tsdb.GetDefaultServiceSource")
}
if len(urls) == 0 {
if len(src.URLs) == 0 {
return nil
}
if !job.baremetal.isRedfishCapable() {
Expand Down Expand Up @@ -253,9 +254,9 @@ func (job *SSendMetricsJob) Do(ctx context.Context, now time.Time) error {
Timestamp: now,
})
}
err = influxdb.SendMetrics(urls, "telegraf", metrics, false)
err = influxdb.SendMetrics(src.URLs, "telegraf", metrics, false)
if err != nil {
return errors.Wrap(err, "influxdb.SendMetrics")
return errors.Wrapf(err, "tsdb.SendMetrics %q", src.Type)
}
job.lastTime = now
return nil
Expand Down
1 change: 1 addition & 0 deletions pkg/cloudcommon/tsdb/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package tsdb // import "yunion.io/x/onecloud/pkg/cloudcommon/tsdb"
55 changes: 55 additions & 0 deletions pkg/cloudcommon/tsdb/tsdb.go
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
}
4 changes: 2 additions & 2 deletions pkg/cloudmon/misc/alerts.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
"yunion.io/x/log"
"yunion.io/x/pkg/errors"

"yunion.io/x/onecloud/pkg/apis"
api "yunion.io/x/onecloud/pkg/apis/monitor"
"yunion.io/x/onecloud/pkg/cloudcommon/tsdb"
"yunion.io/x/onecloud/pkg/cloutpost/options"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/auth"
Expand Down Expand Up @@ -101,7 +101,7 @@ func AlertHistoryReport(ctx context.Context, userCred mcclient.TokenCredential,
}
metrics = append(metrics, metric)
}
urls, err := s.GetServiceURLs(apis.SERVICE_TYPE_INFLUXDB, options.Options.SessionEndpointType)
urls, err := tsdb.GetDefaultServiceSourceURLs(s, options.Options.SessionEndpointType)
if err != nil {
return errors.Wrap(err, "GetServiceURLs")
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/cloudmon/misc/pinger.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (
"yunion.io/x/pkg/util/netutils"
"yunion.io/x/pkg/util/rbacscope"

"yunion.io/x/onecloud/pkg/apis"
api "yunion.io/x/onecloud/pkg/apis/compute"
"yunion.io/x/onecloud/pkg/cloudcommon/tsdb"
"yunion.io/x/onecloud/pkg/cloudmon/options"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/auth"
Expand Down Expand Up @@ -78,7 +78,7 @@ func PingProbe(ctx context.Context, userCred mcclient.TokenCredential, isStart b
}
metrics = append(metrics, m...)
}
urls, err := s.GetServiceURLs(apis.SERVICE_TYPE_INFLUXDB, options.Options.SessionEndpointType)
urls, err := tsdb.GetDefaultServiceSourceURLs(s, options.Options.SessionEndpointType)
if err != nil {
return errors.Wrap(err, "GetServiceURLs")
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/cloudmon/misc/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (

"yunion.io/x/onecloud/pkg/apis"
api "yunion.io/x/onecloud/pkg/apis/identity"
"yunion.io/x/onecloud/pkg/cloudcommon/tsdb"
"yunion.io/x/onecloud/pkg/cloudmon/options"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/auth"
Expand Down Expand Up @@ -100,7 +101,7 @@ func CollectServiceMetrics(ctx context.Context, userCred mcclient.TokenCredentia
}
metrics = append(metrics, part...)
}
urls, err := s.GetServiceURLs(apis.SERVICE_TYPE_INFLUXDB, options.Options.SessionEndpointType)
urls, err := tsdb.GetDefaultServiceSourceURLs(s, options.Options.SessionEndpointType)
if err != nil {
return errors.Wrap(err, "GetServiceURLs")
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/cloudmon/misc/usageservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"yunion.io/x/log"
"yunion.io/x/pkg/errors"

"yunion.io/x/onecloud/pkg/apis"
"yunion.io/x/onecloud/pkg/cloudcommon/tsdb"
"yunion.io/x/onecloud/pkg/cloudmon/options"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/auth"
Expand Down Expand Up @@ -89,8 +89,8 @@ func UsegReport(ctx context.Context, userCred mcclient.TokenCredential, isStart
return errors.Wrap(err, "getDomainAndProjectServerUsage err")
}
dataList = append(dataList, data...)
//写入influDb
urls, err := s.GetServiceURLs(apis.SERVICE_TYPE_INFLUXDB, options.Options.SessionEndpointType)
// 写入 influxdb 或者 VictoriaMetrics
urls, err := tsdb.GetDefaultServiceSourceURLs(s, options.Options.SessionEndpointType)
if err != nil {
return errors.Wrap(err, "GetServiceURLs")
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/cloudmon/providerdriver/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (
"yunion.io/x/log"
"yunion.io/x/pkg/errors"

"yunion.io/x/onecloud/pkg/apis"
api "yunion.io/x/onecloud/pkg/apis/compute"
"yunion.io/x/onecloud/pkg/cloudcommon/tsdb"
"yunion.io/x/onecloud/pkg/cloudmon/options"
"yunion.io/x/onecloud/pkg/mcclient/auth"
"yunion.io/x/onecloud/pkg/util/influxdb"
Expand Down Expand Up @@ -94,7 +94,7 @@ func (self *SBaseCollectDriver) CollectStorageMetrics(ctx context.Context, manag

func (self *SBaseCollectDriver) sendMetrics(ctx context.Context, manager api.CloudproviderDetails, resName string, resCnt int, metrics []influxdb.SMetricData) error {
s := auth.GetAdminSession(ctx, options.Options.Region)
urls, err := s.GetServiceURLs(apis.SERVICE_TYPE_INFLUXDB, options.Options.SessionEndpointType)
urls, err := tsdb.GetDefaultServiceSourceURLs(s, options.Options.SessionEndpointType)
if err != nil {
return errors.Wrap(err, "GetServiceURLs")
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/cloudmon/resources/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import (
"yunion.io/x/log"
"yunion.io/x/pkg/errors"

"yunion.io/x/onecloud/pkg/apis"
api "yunion.io/x/onecloud/pkg/apis/compute"
"yunion.io/x/onecloud/pkg/cloudcommon/db"
"yunion.io/x/onecloud/pkg/cloudcommon/tsdb"
"yunion.io/x/onecloud/pkg/cloudmon/options"
"yunion.io/x/onecloud/pkg/cloudmon/providerdriver"
"yunion.io/x/onecloud/pkg/mcclient"
Expand Down Expand Up @@ -907,7 +907,7 @@ func (self *SResources) CollectMetrics(ctx context.Context, userCred mcclient.To
}
metrics = append(metrics, metric)
}
urls, err := s.GetServiceURLs(apis.SERVICE_TYPE_INFLUXDB, options.Options.SessionEndpointType)
urls, err := tsdb.GetDefaultServiceSourceURLs(s, options.Options.SessionEndpointType)
if err != nil {
log.Errorf("Get influxdb %s service url: %v", options.Options.SessionEndpointType, err)
return
Expand Down
7 changes: 4 additions & 3 deletions pkg/compute/guestdrivers/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ import (
"yunion.io/x/pkg/util/billing"
"yunion.io/x/pkg/util/osprofile"

"yunion.io/x/onecloud/pkg/apis"
api "yunion.io/x/onecloud/pkg/apis/compute"
"yunion.io/x/onecloud/pkg/cloudcommon/consts"
"yunion.io/x/onecloud/pkg/cloudcommon/db/quotas"
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
"yunion.io/x/onecloud/pkg/cloudcommon/tsdb"
guestdriver_types "yunion.io/x/onecloud/pkg/compute/guestdrivers/types"
"yunion.io/x/onecloud/pkg/compute/models"
"yunion.io/x/onecloud/pkg/compute/options"
Expand Down Expand Up @@ -526,11 +526,12 @@ func (drv *SBaseGuestDriver) RequestQgaCommand(ctx context.Context, userCred mcc

func (drv *SBaseGuestDriver) FetchMonitorUrl(ctx context.Context, guest *models.SGuest) string {
s := auth.GetAdminSessionWithPublic(ctx, consts.GetRegion())
influxdbUrl, err := s.GetServiceURL(apis.SERVICE_TYPE_INFLUXDB, options.Options.MonitorEndpointType)
tsdbURL, err := tsdb.GetDefaultServiceSourceURL(s, options.Options.MonitorEndpointType)
if err != nil {
log.Errorf("FetchMonitorUrl fail %s", err)
return ""
}
return influxdbUrl
return tsdbURL
}

func (drv *SBaseGuestDriver) RequestResetNicTrafficLimit(ctx context.Context, task taskman.ITask, host *models.SHost, guest *models.SGuest, input []api.ServerNicTrafficLimit) error {
Expand Down
2 changes: 1 addition & 1 deletion pkg/compute/models/hosts.go
Original file line number Diff line number Diff line change
Expand Up @@ -4226,7 +4226,7 @@ func (hh *SHost) PerformPing(ctx context.Context, userCred mcclient.TokenCredent
}
result := jsonutils.NewDict()
result.Set("name", jsonutils.NewString(hh.GetName()))
dependSvcs := []string{"ntpd", "kafka", "influxdb", "elasticsearch"}
dependSvcs := []string{"ntpd", "kafka", apis.SERVICE_TYPE_INFLUXDB, apis.SERVICE_TYPE_VICTORIA_METRICS, "elasticsearch"}
catalog := auth.GetCatalogData(dependSvcs, options.Options.Region)
if catalog == nil {
return nil, fmt.Errorf("Get catalog error")
Expand Down
4 changes: 2 additions & 2 deletions pkg/compute/models/loadbalanceragents.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
identity_apis "yunion.io/x/onecloud/pkg/apis/identity"
"yunion.io/x/onecloud/pkg/cloudcommon/db"
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
"yunion.io/x/onecloud/pkg/cloudcommon/tsdb"
"yunion.io/x/onecloud/pkg/cloudcommon/validators"
"yunion.io/x/onecloud/pkg/compute/options"
"yunion.io/x/onecloud/pkg/httperrors"
Expand Down Expand Up @@ -279,8 +280,7 @@ func (p *SLoadbalancerAgentParamsTelegraf) updateBy(pp *SLoadbalancerAgentParams
func (p *SLoadbalancerAgentParamsTelegraf) initDefault(data *jsonutils.JSONDict) {
if p.InfluxDbOutputUrl == "" {
baseOpts := &options.Options
u, _ := auth.GetServiceURL("influxdb", baseOpts.Region, "",
identity_apis.EndpointInterfacePublic)
u, _ := tsdb.GetDefaultServiceSourceURL(auth.GetAdminSession(context.Background(), baseOpts.Region), identity_apis.EndpointInterfacePublic)
p.InfluxDbOutputUrl = u
p.InfluxDbOutputUnsafeSsl = true
}
Expand Down
Loading

0 comments on commit ed05401

Please sign in to comment.