types.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package stackdriver
  2. import (
  3. "net/url"
  4. "time"
  5. )
  6. // StackdriverQuery is the query that Grafana sends from the frontend
  7. type StackdriverQuery struct {
  8. Target string
  9. Params url.Values
  10. RefID string
  11. GroupBys []string
  12. AliasBy string
  13. }
  14. type StackdriverBucketOptions struct {
  15. LinearBuckets *struct {
  16. NumFiniteBuckets int64 `json:"numFiniteBuckets"`
  17. Width int64 `json:"width"`
  18. Offset int64 `json:"offset"`
  19. } `json:"linearBuckets"`
  20. ExponentialBuckets *struct {
  21. NumFiniteBuckets int64 `json:"numFiniteBuckets"`
  22. GrowthFactor float64 `json:"growthFactor"`
  23. Scale float64 `json:"scale"`
  24. } `json:"exponentialBuckets"`
  25. ExplicitBuckets *struct {
  26. Bounds []int64 `json:"bounds"`
  27. } `json:"explicitBuckets"`
  28. }
  29. // StackdriverResponse is the data returned from the external Google Stackdriver API
  30. type StackdriverResponse struct {
  31. TimeSeries []struct {
  32. Metric struct {
  33. Labels map[string]string `json:"labels"`
  34. Type string `json:"type"`
  35. } `json:"metric"`
  36. Resource struct {
  37. Type string `json:"type"`
  38. Labels map[string]string `json:"labels"`
  39. } `json:"resource"`
  40. MetricKind string `json:"metricKind"`
  41. ValueType string `json:"valueType"`
  42. Points []struct {
  43. Interval struct {
  44. StartTime time.Time `json:"startTime"`
  45. EndTime time.Time `json:"endTime"`
  46. } `json:"interval"`
  47. Value struct {
  48. DoubleValue float64 `json:"doubleValue"`
  49. StringValue string `json:"stringValue"`
  50. BoolValue bool `json:"boolValue"`
  51. IntValue string `json:"int64Value"`
  52. DistributionValue struct {
  53. Count string `json:"count"`
  54. Mean float64 `json:"mean"`
  55. SumOfSquaredDeviation float64 `json:"sumOfSquaredDeviation"`
  56. Range struct {
  57. Min int `json:"min"`
  58. Max int `json:"max"`
  59. } `json:"range"`
  60. BucketOptions StackdriverBucketOptions `json:"bucketOptions"`
  61. BucketCounts []string `json:"bucketCounts"`
  62. Examplars []struct {
  63. Value float64 `json:"value"`
  64. Timestamp string `json:"timestamp"`
  65. // attachments
  66. } `json:"examplars"`
  67. } `json:"distributionValue"`
  68. } `json:"value"`
  69. } `json:"points"`
  70. } `json:"timeSeries"`
  71. }