Merge pull request #848 from prometheus/fabxc/apifix

promql: add json tags, fix query constructor.
pull/849/head
Julius Volz 10 years ago
commit ef4ba843a2

@ -44,8 +44,8 @@ type Sample struct {
// Scalar is a scalar value evaluated at the set timestamp. // Scalar is a scalar value evaluated at the set timestamp.
type Scalar struct { type Scalar struct {
Value clientmodel.SampleValue Value clientmodel.SampleValue `json:"value"`
Timestamp clientmodel.Timestamp Timestamp clientmodel.Timestamp `json:"timestamp"`
} }
func (s *Scalar) String() string { func (s *Scalar) String() string {
@ -54,8 +54,8 @@ func (s *Scalar) String() string {
// String is a string value evaluated at the set timestamp. // String is a string value evaluated at the set timestamp.
type String struct { type String struct {
Value string Value string `json:"value"`
Timestamp clientmodel.Timestamp Timestamp clientmodel.Timestamp `json:"timestamp"`
} }
func (s *String) String() string { func (s *String) String() string {
@ -279,8 +279,15 @@ func (ng *Engine) Stop() {
} }
// NewInstantQuery returns an evaluation query for the given expression at the given time. // NewInstantQuery returns an evaluation query for the given expression at the given time.
func (ng *Engine) NewInstantQuery(es string, ts clientmodel.Timestamp) (Query, error) { func (ng *Engine) NewInstantQuery(qs string, ts clientmodel.Timestamp) (Query, error) {
return ng.NewRangeQuery(es, ts, ts, 0) expr, err := ParseExpr(qs)
if err != nil {
return nil, err
}
qry := ng.newQuery(expr, ts, ts, 0)
qry.q = qs
return qry, nil
} }
// NewRangeQuery returns an evaluation query for the given time range and with // NewRangeQuery returns an evaluation query for the given time range and with

Loading…
Cancel
Save