models.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. package tsdb
  2. import "github.com/grafana/grafana/pkg/components/simplejson"
  3. type Query struct {
  4. RefId string
  5. Query string
  6. Model *simplejson.Json
  7. Depends []string
  8. DataSource *DataSourceInfo
  9. Results []*TimeSeries
  10. Exclude bool
  11. }
  12. type QuerySlice []*Query
  13. type Request struct {
  14. TimeRange TimeRange
  15. MaxDataPoints int
  16. Queries QuerySlice
  17. }
  18. type Response struct {
  19. BatchTimings []*BatchTiming
  20. Results map[string]*QueryResult
  21. }
  22. type DataSourceInfo struct {
  23. Id int64
  24. Name string
  25. PluginId string
  26. Url string
  27. Password string
  28. User string
  29. Database string
  30. BasicAuth bool
  31. BasicAuthUser string
  32. BasicAuthPassword string
  33. }
  34. type BatchTiming struct {
  35. TimeElapsed int64
  36. }
  37. type BatchResult struct {
  38. Error error
  39. QueryResults map[string]*QueryResult
  40. Timings *BatchTiming
  41. }
  42. type QueryResult struct {
  43. Error error
  44. RefId string
  45. Series TimeSeriesSlice
  46. }
  47. type TimeSeries struct {
  48. Name string `json:"name"`
  49. Points [][2]*float64 `json:"points"`
  50. }
  51. type TimeSeriesSlice []*TimeSeries
  52. func NewTimeSeries(name string, points [][2]*float64) *TimeSeries {
  53. return &TimeSeries{
  54. Name: name,
  55. Points: points,
  56. }
  57. }