Skip to content

Commit 2d8f46d

Browse files
committed
Add Models
1 parent 9412ded commit 2d8f46d

28 files changed

Lines changed: 1009 additions & 20 deletions

.vs/slnx.sqlite

24 KB
Binary file not shown.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using Newtonsoft.Json;
2+
using System.Collections.Generic;
3+
4+
namespace OpenTSDB.Core.Models.Histogram
5+
{
6+
/// <summary>
7+
/// Available with OpenTSDB 2.4
8+
/// This endpoint allows for storing histogram data in OpenTSDB over HTTP as an alternative to the Telnet interface. Histogram write Request can only be performed via content associated with the POST method. Queries over histogram data are performed via the query endpoints.
9+
/// </summary>
10+
/// <remarks>If the content you provide with the request cannot be parsed, such JSON content missing a quotation mark or curly brace, then all of the datapoints will be discarded. The API will return an error with details about what went wrong.</remarks>
11+
public class HistogramRequest : DataPoint<string>
12+
{
13+
/// <summary>
14+
/// When writing histograms or sketches other than the default simple bucketed histogram,
15+
/// this value must be set to the ID of the proper histogram codec as defined in the tsd.core.histograms.config configuration setting.
16+
/// The value must be between 0 and 255. When given, the value must be set.
17+
/// </summary>
18+
/// <example>1</example>
19+
[JsonProperty("id")]
20+
public int Id { get; set; }
21+
22+
/// <summary>
23+
/// A map of bucket lower and upper bounds (separated by commas) as keys with integer counter bucket values
24+
/// </summary>
25+
/// <example>
26+
/// {"0,1.75":12,"1.75,3.5":16}
27+
/// </example>
28+
[JsonProperty("buckets")]
29+
public Dictionary<string, int> Buckets { get; set; }
30+
31+
/// <summary>
32+
/// The count of measurements lower than the lowest bucket lower bound. Default is zero.
33+
/// </summary>
34+
/// <example>0</example>
35+
[JsonProperty("underflow")]
36+
public int Underflow { get; set; }
37+
38+
/// <summary>
39+
///The count of measurements higher than the highest bucket upper bound. Default is zero.
40+
/// </summary>
41+
/// <example>0</example>
42+
[JsonProperty("overflow")]
43+
public int Overflow { get; set; }
44+
}
45+
}
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
using Newtonsoft.Json;
2+
3+
namespace OpenTSDB.Core.Models.Query
4+
{
5+
/// <summary>
6+
/// http://opentsdb.net/docs/build/html/api_http/query/index.html
7+
/// </summary>
8+
public class QueryRequest
9+
{
10+
/// <summary>
11+
/// The start time for the query. This can be a relative or absolute timestamp
12+
/// </summary>
13+
/// <example>1h-ago</example>
14+
[JsonProperty("start")]
15+
public string Start { get; set; }
16+
17+
/// <summary>
18+
/// An end time for the query. If not supplied, the TSD will assume the local system time on the server.
19+
/// This may be a relative or absolute timestamp
20+
/// </summary>
21+
/// <example>1h-ago</example>
22+
[JsonProperty("end")]
23+
public string End { get; set; }
24+
25+
/// <summary>
26+
/// One or more sub queries used to select the time series to return.
27+
/// These may be metric m or TSUID tsuids queries
28+
/// </summary>
29+
[JsonProperty("queries")]
30+
public SubQueryRequest[] Queries { get; set; }
31+
32+
/// <summary>
33+
/// Whether or not to return annotations with a query.
34+
/// The default is to return annotations for the requested timespan but this flag can disable the return.
35+
/// This affects both local and global notes and overrides globalAnnotations
36+
/// </summary>
37+
/// <example>false</example>
38+
[JsonProperty("noAnnotations")]
39+
public bool NoAnnotations { get; set; }
40+
41+
/// <summary>
42+
/// Whether or not the query should retrieve global annotations for the requested timespan
43+
/// </summary>
44+
[JsonProperty("globalAnnotations")]
45+
public bool GlobalAnnotations { get; set; }
46+
47+
/// <summary>
48+
/// Whether or not to Response data point timestamps in milliseconds or seconds.
49+
/// The msResolution flag is recommended.
50+
/// If this flag is not provided and there are multiple data points within a second, those data points will be down
51+
/// sampled using the query's aggregation function.
52+
/// </summary>
53+
[JsonProperty("msResolution")]
54+
public bool MsResolutions { get; set; }
55+
56+
/// <summary>
57+
/// Whether or not to Response the TSUIDs associated with timeseries in the results.
58+
/// If multiple time series were aggregated into one set, multiple TSUIDs will be returned in a sorted manner
59+
/// </summary>
60+
[JsonProperty("showTSUIDs")]
61+
public bool ShowTsuids { get; set; }
62+
63+
/// <summary>
64+
/// Whether or not to show a summary of timings surrounding the query in the results.
65+
/// This creates another object in the map that is unlike the data point objects.
66+
/// </summary>
67+
[JsonProperty("showSummary")]
68+
public bool ShowSummary { get; set; }
69+
70+
/// <summary>
71+
/// Whether or not to show detailed timings surrounding the query in the results.
72+
/// This creates another object in the map that is unlike the data point objects
73+
/// </summary>
74+
[JsonProperty("showStats")]
75+
public bool ShowStats { get; set; }
76+
77+
/// <summary>
78+
/// Whether or not to return the original sub query with the query results.
79+
/// If the request contains many sub queries then this is a good way to determine which results belong to which sub
80+
/// query.
81+
/// Note that in the case of a * or wildcard query, this can produce a lot of duplicate Response.
82+
/// </summary>
83+
[JsonProperty("showQuery")]
84+
public bool ShowQuery { get; set; }
85+
86+
/// <summary>
87+
/// Can be passed to the JSON with a POST to delete any data points that match the given query.
88+
/// </summary>
89+
[JsonProperty("delete")]
90+
public bool Delete { get; set; }
91+
92+
/// <summary>
93+
/// An optional timezone for calendar-based downsampling.
94+
/// Must be a valid timezone database name supported by the JRE installed on the TSD server.
95+
/// </summary>
96+
[JsonProperty("timezone")]
97+
public string TimeZone { get; set; }
98+
99+
/// <summary>
100+
/// Whether or not use the calendar based on the given timezone for downsampling intervals
101+
/// </summary>
102+
[JsonProperty("useCalendar")]
103+
public bool UseCalendar { get; set; }
104+
}
105+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using Newtonsoft.Json;
2+
using System.Collections.Generic;
3+
4+
namespace OpenTSDB.Core.Models.Query
5+
{
6+
public class SubQueryRequest
7+
{
8+
[JsonProperty("aggregator")]
9+
public string Aggregator { get; set; }
10+
11+
[JsonProperty("metric")]
12+
public string Metric { get; set; }
13+
14+
[JsonProperty("rate")]
15+
public bool Rate { get; set; }
16+
17+
[JsonProperty("rateOptions")]
18+
public Dictionary<string, string> RateOptions { get; set; }
19+
20+
[JsonProperty("downsample")]
21+
public string Downsample { get; set; }
22+
23+
[JsonProperty("tags")]
24+
public Tags Tags { get; set; }
25+
26+
[JsonProperty("filters")]
27+
public IEnumerable<string> Filters { get; set; }
28+
29+
[JsonProperty("explicitTags")]
30+
public bool ExplicitTags { get; set; }
31+
32+
[JsonProperty("percentiles")]
33+
public IEnumerable<string> Percentiles { get; set; }
34+
}
35+
36+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using Newtonsoft.Json;
2+
3+
namespace OpenTSDB.Core.Models.Rollup
4+
{
5+
/// <summary>
6+
/// Rollup and pre-aggregate values are extensions of the put object with three additional fields.
7+
/// </summary>
8+
public class RollupRequest<T>: DataPoint<T>
9+
{
10+
/// <summary>
11+
/// A time interval reflecting what timespan the rollup value represents.
12+
/// The interval consists of <amount><unit> similar to a downsampler or relative query timestamp.
13+
/// E.g. 6h for 5 hours of data, 30m for 30 minutes of data.
14+
/// </summary>
15+
/// <example>1h</example>
16+
[JsonProperty("interval")]
17+
public string Interval { get; set; }
18+
19+
/// <summary>
20+
/// An aggregation function used to generate the rollup value. Must match a supplied TSDB aggregator.
21+
/// </summary>
22+
/// <example>SUM</example>
23+
[JsonProperty("aggregator")]
24+
public string Aggregator { get; set; }
25+
26+
/// <summary>
27+
/// An aggregation function used to generate the pre-aggregate value. Must match a supplied TSDB aggregator.
28+
/// </summary>
29+
/// <example>COUNT</example>
30+
[JsonProperty("groupByAggregator")]
31+
public string GroupByAggregator { get; set; }
32+
}
33+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using Newtonsoft.Json;
2+
using System.Collections.Generic;
3+
4+
namespace OpenTSDB.Core.Models.Search.Annotation
5+
{
6+
public class AnnotationResultItem
7+
{
8+
[JsonProperty("notes")]
9+
public string Notes { get; set; }
10+
11+
[JsonProperty("description")]
12+
public string Description { get; set; }
13+
14+
[JsonProperty("tsuid")]
15+
public string Tsuid { get; set; }
16+
17+
[JsonProperty("custom")]
18+
public Dictionary<string,string> Custom { get; set; }
19+
20+
[JsonProperty("endTime")]
21+
public int endTime { get; set; }
22+
23+
[JsonProperty("startTime")]
24+
public int startTime { get; set; }
25+
}
26+
27+
28+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System;
2+
using System.Text;
3+
4+
namespace OpenTSDB.Core.Models.Search.Annotation
5+
{
6+
public class SearchAnnotationResponse : SearchResponse<AnnotationResultItem>
7+
{
8+
}
9+
10+
11+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace OpenTSDB.Core.Models.Search.Lookup
2+
{
3+
public class SearchLookupResponse : SearchResponse<ResultItem>
4+
{
5+
6+
}
7+
8+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using Newtonsoft.Json;
2+
3+
namespace OpenTSDB.Core.Models.Search.Lookup
4+
{
5+
public class SearchLookupRequest
6+
{
7+
/// <summary>
8+
/// Ignored for lookup queries.
9+
/// </summary>
10+
[JsonProperty("query")]
11+
public string Query { get; set; }
12+
13+
/// <summary>
14+
/// Whether or not to use the meta data table or the raw data table. The raw table will be much slower.
15+
/// </summary>
16+
[JsonProperty("useMeta")]
17+
public bool UseMeta { get; set; } = true;
18+
/// <summary>
19+
/// The maximum number of items returned in the result set.
20+
/// </summary>
21+
[JsonProperty("limit")]
22+
public int Limit { get; set; }
23+
24+
/// <summary>
25+
/// Ignored for lookup queries, always the default.
26+
/// </summary>
27+
[JsonProperty("startIndex")]
28+
public int StartIndex { get; set; }
29+
30+
}
31+
32+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using Newtonsoft.Json;
2+
using System.Collections.Generic;
3+
4+
namespace OpenTSDB.Core.Models.Search
5+
{
6+
public class ResultItem
7+
{
8+
[JsonProperty("tags")]
9+
public Dictionary<string, string> Tags { get; set; }
10+
11+
[JsonProperty("metric")]
12+
public string Metric { get; set; }
13+
14+
[JsonProperty("tsuid")]
15+
public string Tsuid { get; set; }
16+
}
17+
18+
19+
}

0 commit comments

Comments
 (0)