Skip to content

Commit 009a3db

Browse files
committed
add models
1 parent c8e2f9c commit 009a3db

19 files changed

Lines changed: 356 additions & 8 deletions

src/OpenTSDBSample/Program.cs

Lines changed: 57 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
using System.Net.Http;
88
using Newtonsoft.Json;
99
using System.Threading.Tasks;
10+
using OpenTSDB.Core.Models.Rollup;
11+
using OpenTSDB.Core.Models.Histogram;
1012

1113
namespace OpenTSDBSample
1214
{
@@ -16,31 +18,78 @@ class Program
1618
static void Main(string[] args)
1719
{
1820
Console.WriteLine("Init Api Url");
19-
ApiUrlConfig.ChangeBaseUrl("http://192.168.1.12:4242/");
21+
ApiUrlConfig.ChangeBaseUrl("http://codebim.cn:4242/");
2022

2123
Test test = new Test();
22-
test.Run();
24+
// test.Put();
25+
test.histogram();
2326
Console.ReadKey();
24-
2527
}
2628

2729
}
2830

2931
class Test
3032
{
3133
OpenTsdbClient apiClient = new OpenTsdbClient();
32-
public async void Run()
34+
public async void Put()
3335
{
36+
3437
var list = new List<DataPoint<float>>();
35-
DataPoint<float> dataPoint = new DataPoint<float>();
38+
for(int i = 0; i<= 50; i++)
39+
{
40+
float value = (float)new Random().NextDouble();
41+
DataPoint<float> dataPoint = new DataPoint<float>();
42+
dataPoint.Metric = "bridge";
43+
dataPoint.Timestamp = ConvertDateTimeInt(DateTime.Now.AddHours(1));
44+
dataPoint.Value = value;
45+
dataPoint.Tags.Add("host", "YL-01-01");
46+
dataPoint.Tags.Add("dc", "lga");
47+
list.Add(dataPoint);
48+
}
49+
50+
51+
// var result = await apiClient.PostAsync<dynamic>("api/put?summary", list);
52+
53+
54+
var result2 = await apiClient.PostAsync<dynamic>("/api/put/?details&sync&sync_timeout=60000", list);
55+
if (result2 != null)
56+
{
57+
Console.WriteLine(result2);
58+
}
59+
60+
}
61+
62+
public async void Rollup()
63+
{
64+
65+
RollupRequest<float> dataPoint = new RollupRequest<float>();
3666
dataPoint.Metric = "bridge";
37-
dataPoint.Timestamp = ConvertDateTimeInt(DateTime.Now);
67+
dataPoint.Timestamp = 1575022650;
3868
dataPoint.Value = 23.4f;
3969
dataPoint.Tags.Add("host", "YL-01-01");
4070
dataPoint.Tags.Add("dc", "lga");
41-
list.Add(dataPoint);
71+
//dataPoint.Interval = "1h";
72+
//dataPoint.Aggregator= "SUM";
73+
//dataPoint.GroupByAggregator = "SUM";
74+
var result = await apiClient.PostAsync<dynamic>("/api/rollup?summary", dataPoint);
75+
Console.WriteLine(result);
76+
}
77+
78+
public async void histogram()
79+
{
80+
HistogramRequest dataPoint = new HistogramRequest();
81+
dataPoint.Metric = "bridge";
82+
dataPoint.Timestamp = ConvertDateTimeInt(DateTime.Now);
83+
dataPoint.Overflow = 1;
84+
dataPoint.Underflow = 0;
85+
dataPoint.Buckets = new Dictionary<string, int>()
86+
{
87+
{ "0,1.75", 12 }, {"1.75,3.5", 16 }
88+
};
89+
dataPoint.Tags.Add("host", "YL-01-01");
90+
dataPoint.Tags.Add("dc", "lga");
4291

43-
var result = await apiClient.PostAsync<dynamic>("api/put?summary", list);
92+
var result = await apiClient.PostAsync<dynamic>("/api/put?details", dataPoint);
4493
Console.WriteLine(result);
4594
}
4695

67 KB
Binary file not shown.
23.5 KB
Binary file not shown.
Binary file not shown.
52.5 KB
Binary file not shown.
14.2 KB
Binary file not shown.
Lines changed: 281 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,281 @@
1+
{
2+
"runtimeTarget": {
3+
"name": ".NETCoreApp,Version=v3.0",
4+
"signature": ""
5+
},
6+
"compilationOptions": {},
7+
"targets": {
8+
".NETCoreApp,Version=v3.0": {
9+
"OpenTSDBSample/1.0.0": {
10+
"dependencies": {
11+
"OpenTSDB.Core": "0.2.0",
12+
"Z.ExtensionMethods": "2.1.1"
13+
},
14+
"runtime": {
15+
"OpenTSDBSample.dll": {}
16+
}
17+
},
18+
"Flurl/2.8.2": {
19+
"runtime": {
20+
"lib/netstandard2.0/Flurl.dll": {
21+
"assemblyVersion": "2.8.2.0",
22+
"fileVersion": "2.8.2.0"
23+
}
24+
}
25+
},
26+
"Flurl.Http/2.4.2": {
27+
"dependencies": {
28+
"Flurl": "2.8.2",
29+
"Newtonsoft.Json": "12.0.2",
30+
"System.Text.Encoding.CodePages": "4.5.1"
31+
},
32+
"runtime": {
33+
"lib/netstandard2.0/Flurl.Http.dll": {
34+
"assemblyVersion": "2.4.2.0",
35+
"fileVersion": "2.4.2.0"
36+
}
37+
}
38+
},
39+
"Microsoft.CSharp/4.5.0": {},
40+
"Microsoft.NETCore.Platforms/2.1.2": {},
41+
"Microsoft.Win32.Registry/4.5.0": {
42+
"dependencies": {
43+
"System.Security.AccessControl": "4.5.0",
44+
"System.Security.Principal.Windows": "4.5.0"
45+
}
46+
},
47+
"Newtonsoft.Json/12.0.2": {
48+
"runtime": {
49+
"lib/netstandard2.0/Newtonsoft.Json.dll": {
50+
"assemblyVersion": "12.0.0.0",
51+
"fileVersion": "12.0.2.23222"
52+
}
53+
}
54+
},
55+
"runtime.native.System.Data.SqlClient.sni/4.4.0": {
56+
"dependencies": {
57+
"runtime.win-arm64.runtime.native.System.Data.SqlClient.sni": "4.4.0",
58+
"runtime.win-x64.runtime.native.System.Data.SqlClient.sni": "4.4.0",
59+
"runtime.win-x86.runtime.native.System.Data.SqlClient.sni": "4.4.0"
60+
}
61+
},
62+
"runtime.win-arm64.runtime.native.System.Data.SqlClient.sni/4.4.0": {
63+
"runtimeTargets": {
64+
"runtimes/win-arm64/native/sni.dll": {
65+
"rid": "win-arm64",
66+
"assetType": "native",
67+
"fileVersion": "4.6.25512.1"
68+
}
69+
}
70+
},
71+
"runtime.win-x64.runtime.native.System.Data.SqlClient.sni/4.4.0": {
72+
"runtimeTargets": {
73+
"runtimes/win-x64/native/sni.dll": {
74+
"rid": "win-x64",
75+
"assetType": "native",
76+
"fileVersion": "4.6.25512.1"
77+
}
78+
}
79+
},
80+
"runtime.win-x86.runtime.native.System.Data.SqlClient.sni/4.4.0": {
81+
"runtimeTargets": {
82+
"runtimes/win-x86/native/sni.dll": {
83+
"rid": "win-x86",
84+
"assetType": "native",
85+
"fileVersion": "4.6.25512.1"
86+
}
87+
}
88+
},
89+
"System.Data.SqlClient/4.5.1": {
90+
"dependencies": {
91+
"Microsoft.Win32.Registry": "4.5.0",
92+
"System.Security.Principal.Windows": "4.5.0",
93+
"System.Text.Encoding.CodePages": "4.5.1",
94+
"runtime.native.System.Data.SqlClient.sni": "4.4.0"
95+
},
96+
"runtime": {
97+
"lib/netcoreapp2.1/System.Data.SqlClient.dll": {
98+
"assemblyVersion": "4.4.0.0",
99+
"fileVersion": "4.6.26606.5"
100+
}
101+
},
102+
"runtimeTargets": {
103+
"runtimes/unix/lib/netcoreapp2.1/System.Data.SqlClient.dll": {
104+
"rid": "unix",
105+
"assetType": "runtime",
106+
"assemblyVersion": "4.4.0.0",
107+
"fileVersion": "4.6.26606.5"
108+
},
109+
"runtimes/win/lib/netcoreapp2.1/System.Data.SqlClient.dll": {
110+
"rid": "win",
111+
"assetType": "runtime",
112+
"assemblyVersion": "4.4.0.0",
113+
"fileVersion": "4.6.26606.5"
114+
}
115+
}
116+
},
117+
"System.Runtime.CompilerServices.Unsafe/4.5.2": {},
118+
"System.Security.AccessControl/4.5.0": {
119+
"dependencies": {
120+
"Microsoft.NETCore.Platforms": "2.1.2",
121+
"System.Security.Principal.Windows": "4.5.0"
122+
}
123+
},
124+
"System.Security.Principal.Windows/4.5.0": {
125+
"dependencies": {
126+
"Microsoft.NETCore.Platforms": "2.1.2"
127+
}
128+
},
129+
"System.Text.Encoding.CodePages/4.5.1": {
130+
"dependencies": {
131+
"Microsoft.NETCore.Platforms": "2.1.2",
132+
"System.Runtime.CompilerServices.Unsafe": "4.5.2"
133+
}
134+
},
135+
"Z.ExtensionMethods/2.1.1": {
136+
"dependencies": {
137+
"Microsoft.CSharp": "4.5.0",
138+
"System.Data.SqlClient": "4.5.1"
139+
},
140+
"runtime": {
141+
"lib/netstandard2.0/Z.ExtensionMethods.dll": {
142+
"assemblyVersion": "2.1.1.0",
143+
"fileVersion": "2.1.1.0"
144+
}
145+
}
146+
},
147+
"OpenTSDB.Core/0.2.0": {
148+
"dependencies": {
149+
"Flurl.Http": "2.4.2"
150+
},
151+
"runtime": {
152+
"OpenTSDB.Core.dll": {}
153+
}
154+
}
155+
}
156+
},
157+
"libraries": {
158+
"OpenTSDBSample/1.0.0": {
159+
"type": "project",
160+
"serviceable": false,
161+
"sha512": ""
162+
},
163+
"Flurl/2.8.2": {
164+
"type": "package",
165+
"serviceable": true,
166+
"sha512": "sha512-3VEYAqkGTGHgla4xuyEB4d8XGLeMX2k05C4WfI7YmKQHsL7RhoGu3L6h1xsKKTPFWjEL13p09XOIGwD1pQ86dg==",
167+
"path": "flurl/2.8.2",
168+
"hashPath": "flurl.2.8.2.nupkg.sha512"
169+
},
170+
"Flurl.Http/2.4.2": {
171+
"type": "package",
172+
"serviceable": true,
173+
"sha512": "sha512-VfSJ0DKzh6kf2IOZGG1/JpHajhtqzGp1t+M1QSyFGse7c4Gg1DpH80LTveYea2hV1BEtvPPEp6A4iZ78D8bxGQ==",
174+
"path": "flurl.http/2.4.2",
175+
"hashPath": "flurl.http.2.4.2.nupkg.sha512"
176+
},
177+
"Microsoft.CSharp/4.5.0": {
178+
"type": "package",
179+
"serviceable": true,
180+
"sha512": "sha512-EGoBmf3Na2ppbhPePDE9PlX81r1HuOZH5twBrq7couJZiPTjUnD3648balerQJO6EJ8Sj+43+XuRwQ7r+3tE3w==",
181+
"path": "microsoft.csharp/4.5.0",
182+
"hashPath": "microsoft.csharp.4.5.0.nupkg.sha512"
183+
},
184+
"Microsoft.NETCore.Platforms/2.1.2": {
185+
"type": "package",
186+
"serviceable": true,
187+
"sha512": "sha512-7J7veIH7Mu6zc4llWnM7YRgTv9+Ew+JWkkDj0K7cEe8wuFA6HRt6STtwux2g+qjpDXeYeWsK0UQ3uIgRiTYHIg==",
188+
"path": "microsoft.netcore.platforms/2.1.2",
189+
"hashPath": "microsoft.netcore.platforms.2.1.2.nupkg.sha512"
190+
},
191+
"Microsoft.Win32.Registry/4.5.0": {
192+
"type": "package",
193+
"serviceable": true,
194+
"sha512": "sha512-enFJdJDWljYjOWDgVZN+JmC9I2oP1JCGhgk5d2RKBZ5OEJsAM6zz5Zktv1nV9tQFAnPCj8AXU0QBuxTVCYjvrA==",
195+
"path": "microsoft.win32.registry/4.5.0",
196+
"hashPath": "microsoft.win32.registry.4.5.0.nupkg.sha512"
197+
},
198+
"Newtonsoft.Json/12.0.2": {
199+
"type": "package",
200+
"serviceable": true,
201+
"sha512": "sha512-rTK0s2EKlfHsQsH6Yx2smvcTCeyoDNgCW7FEYyV01drPlh2T243PR2DiDXqtC5N4GDm4Ma/lkxfW5a/4793vbA==",
202+
"path": "newtonsoft.json/12.0.2",
203+
"hashPath": "newtonsoft.json.12.0.2.nupkg.sha512"
204+
},
205+
"runtime.native.System.Data.SqlClient.sni/4.4.0": {
206+
"type": "package",
207+
"serviceable": true,
208+
"sha512": "sha512-A8v6PGmk+UGbfWo5Ixup0lPM4swuSwOiayJExZwKIOjTlFFQIsu3QnDXECosBEyrWSPryxBVrdqtJyhK3BaupQ==",
209+
"path": "runtime.native.system.data.sqlclient.sni/4.4.0",
210+
"hashPath": "runtime.native.system.data.sqlclient.sni.4.4.0.nupkg.sha512"
211+
},
212+
"runtime.win-arm64.runtime.native.System.Data.SqlClient.sni/4.4.0": {
213+
"type": "package",
214+
"serviceable": true,
215+
"sha512": "sha512-LbrynESTp3bm5O/+jGL8v0Qg5SJlTV08lpIpFesXjF6uGNMWqFnUQbYBJwZTeua6E/Y7FIM1C54Ey1btLWupdg==",
216+
"path": "runtime.win-arm64.runtime.native.system.data.sqlclient.sni/4.4.0",
217+
"hashPath": "runtime.win-arm64.runtime.native.system.data.sqlclient.sni.4.4.0.nupkg.sha512"
218+
},
219+
"runtime.win-x64.runtime.native.System.Data.SqlClient.sni/4.4.0": {
220+
"type": "package",
221+
"serviceable": true,
222+
"sha512": "sha512-38ugOfkYJqJoX9g6EYRlZB5U2ZJH51UP8ptxZgdpS07FgOEToV+lS11ouNK2PM12Pr6X/PpT5jK82G3DwH/SxQ==",
223+
"path": "runtime.win-x64.runtime.native.system.data.sqlclient.sni/4.4.0",
224+
"hashPath": "runtime.win-x64.runtime.native.system.data.sqlclient.sni.4.4.0.nupkg.sha512"
225+
},
226+
"runtime.win-x86.runtime.native.System.Data.SqlClient.sni/4.4.0": {
227+
"type": "package",
228+
"serviceable": true,
229+
"sha512": "sha512-YhEdSQUsTx+C8m8Bw7ar5/VesXvCFMItyZF7G1AUY+OM0VPZUOeAVpJ4Wl6fydBGUYZxojTDR3I6Bj/+BPkJNA==",
230+
"path": "runtime.win-x86.runtime.native.system.data.sqlclient.sni/4.4.0",
231+
"hashPath": "runtime.win-x86.runtime.native.system.data.sqlclient.sni.4.4.0.nupkg.sha512"
232+
},
233+
"System.Data.SqlClient/4.5.1": {
234+
"type": "package",
235+
"serviceable": true,
236+
"sha512": "sha512-HV8pqcYlH7bNnX1n4i6F5RG7r6+WVErE2jUMNjXRrrkLFVIWLoerXtXDFs80pHvDBjxoG4rG0p2BUH3iXRs7hQ==",
237+
"path": "system.data.sqlclient/4.5.1",
238+
"hashPath": "system.data.sqlclient.4.5.1.nupkg.sha512"
239+
},
240+
"System.Runtime.CompilerServices.Unsafe/4.5.2": {
241+
"type": "package",
242+
"serviceable": true,
243+
"sha512": "sha512-hMkdWxksypQlFXB7JamQegDscxEAQO4FHd/lw/zlSZU9dZgAij65xjCrXer183wvoNAzJic5zzjj2oc9/dloWg==",
244+
"path": "system.runtime.compilerservices.unsafe/4.5.2",
245+
"hashPath": "system.runtime.compilerservices.unsafe.4.5.2.nupkg.sha512"
246+
},
247+
"System.Security.AccessControl/4.5.0": {
248+
"type": "package",
249+
"serviceable": true,
250+
"sha512": "sha512-vW8Eoq0TMyz5vAG/6ce483x/CP83fgm4SJe5P8Tb1tZaobcvPrbMEL7rhH1DRdrYbbb6F0vq3OlzmK0Pkwks5A==",
251+
"path": "system.security.accesscontrol/4.5.0",
252+
"hashPath": "system.security.accesscontrol.4.5.0.nupkg.sha512"
253+
},
254+
"System.Security.Principal.Windows/4.5.0": {
255+
"type": "package",
256+
"serviceable": true,
257+
"sha512": "sha512-U77HfRXlZlOeIXd//Yoj6Jnk8AXlbeisf1oq1os+hxOGVnuG+lGSfGqTwTZBoORFF6j/0q7HXIl8cqwQ9aUGqQ==",
258+
"path": "system.security.principal.windows/4.5.0",
259+
"hashPath": "system.security.principal.windows.4.5.0.nupkg.sha512"
260+
},
261+
"System.Text.Encoding.CodePages/4.5.1": {
262+
"type": "package",
263+
"serviceable": true,
264+
"sha512": "sha512-Eu3dyUUqDFkuskrrK54VLWC41EVANJNo5vzjojnGAphH+FV63NJg3zs5x0TvRaYDTZ2y+86eIOK43Hg2NXiw7w==",
265+
"path": "system.text.encoding.codepages/4.5.1",
266+
"hashPath": "system.text.encoding.codepages.4.5.1.nupkg.sha512"
267+
},
268+
"Z.ExtensionMethods/2.1.1": {
269+
"type": "package",
270+
"serviceable": true,
271+
"sha512": "sha512-HLpIUSYL8kVTKBeeMVjQMN63E7RHO+1aGt2aZBjrFhHPjJVsOUh26KDQEDMsjOjlh/hQTqZQEJJc+gNhyQxq4g==",
272+
"path": "z.extensionmethods/2.1.1",
273+
"hashPath": "z.extensionmethods.2.1.1.nupkg.sha512"
274+
},
275+
"OpenTSDB.Core/0.2.0": {
276+
"type": "project",
277+
"serviceable": false,
278+
"sha512": ""
279+
}
280+
}
281+
}
7.5 KB
Binary file not shown.
156 KB
Binary file not shown.
984 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)