-
Notifications
You must be signed in to change notification settings - Fork 3
Home
LUYONGQIANG edited this page Dec 4, 2019
·
8 revisions
Welcome to the OpenTSDB.Core wiki!
dotnet new console -o myApp
cd myApp
The dotnet command creates a new application of type console for you. The -o parameter creates a directory named myApp where your app is stored, and populates it with the required files. The cd myApp command puts you into the newly created app directory.
dotnet add package OpenTSDB.Core --version 0.2.0
dotnet build
class Program {
static void Main(string[] args)
{
Console.WriteLine("Init Api Url");
ApiUrlConfig.ChangeBaseUrl("http://192.168.1.22:4242/");
Test test = new Test();
test.Run();
Console.ReadKey();
}
}
class Test {
OpenTsdbClient apiClient = new OpenTsdbClient();
public async void Run()
{
var list = new List<DataPoint<float>>();
DataPoint<float> dataPoint = new DataPoint<float>();
dataPoint.Metric = "bridge";
dataPoint.Timestamp = ConvertDateTimeInt(DateTime.Now);
dataPoint.Value = 23.4f;
dataPoint.Tags.Add("host", "YL-01-01");
dataPoint.Tags.Add("dc", "lga");
list.Add(dataPoint);
var result = await apiClient.PostAsync<dynamic>("api/put?summary", list);
Console.WriteLine(result);
}
public static int ConvertDateTimeInt(System.DateTime time)
{
System.DateTime startTime =new DateTime(1970, 1, 1);
return (int)(time - startTime).TotalSeconds;
}
}
/s
/api/aggregators
/api/annotation
/api/config
/api/dropcaches
/api/put
/api/rollup
/api/histogram
/api/query
/api/search
/api/serializers
/api/stats
/api/suggest
/api/tree
/api/uid
/api/version