Skip to content

Latest commit

 

History

History
156 lines (110 loc) · 8.01 KB

README.md

File metadata and controls

156 lines (110 loc) · 8.01 KB

LogicMonitor.DataSDK - the C# library for the LogicMonitor API-Ingest Rest API

CodeQL .NET

LogicMonitor is a SaaS-based performance monitoring platform that provides full visibility into complex, hybrid infrastructures, offering granular performance monitoring and actionable data and insights. API-Ingest provides the entry point in the form of public rest APIs for ingesting metrics into LogicMonitor. For using this application users have to create either LMv1 authentication token or Bearer token from LogicMonitor platform (a.k.a santaba).

  • SDK version: 0.1.0-alpha

👉 API reference docs

👉 NuGet package

Frameworks supported

  • .NET Core >= 3.1

Dependencies

Metrics Ingestion Example.

SDK must be configured with LogicMonitor.DataSDK Configuration class. While using LMv1 authentication set AccessID and AccessKey properties, In Case of BearerToken Authentication set Bearer Token property. Company's name or Account name must be passed to Company property. All properties can be set using environment variable.

System property Environment variable Description
Configration.company ACCOUNT_NAME Account name (Company Name) is your organization name
Configration.AccessID API_ACCESS_ID Access id while using LMv1 authentication. (Not needed while using Bearer API )
Configration.AccessKey API_ACCESS_KEY Access key while using LMv1 authentication. (Not needed while using Bearer API )
Configration.BearerToken API_BEARER_TOKEN BearerToken while using Bearer authentication. (Not needed while using LMv1 API)

For metrics ingestion user must create a object of Resource, DataSource, DataSourceInstance and DataPoint using LogicMonitor.DataSDK.Model namespace, also dictonary should be created in which 'Key' hold the Time(in epoch) for which data is being emitted and 'Value' will the the value of datapoint.

//Pass autheticate variable as Environment variable.
ApiClient apiClient = new ApiClient();

Metrics metrics = new Metrics(batch: false, interval: 0, responseInterface, apiClient);

Resource resource = new Resource(name: resourceName, ids: resourceIds, create: true);
DataSource dataSource = new DataSource(Name: dataSourceName, Group: dataSourceGroup);
DataSourceInstance dataSourceInstance = new DataSourceInstance(name: InstanceName);
DataPoint dataPoint = new DataPoint(name: CpuUsage);
Dictionary<string, string> CpuUsageValue = new Dictionary<string, string>();
    
    
CpuUsageValue.Add(epochTime, metricData);
metrics.SendMetrics(resource: resource, dataSource: dataSource, dataSourceInstance: dataSourceInstance, dataPoint: dataPoint, values: CpuUsageValue);

To Pass autheticate variable as Environment variable use the following command.: While Using LMv1 Authentication:

export ACCOUNT_NAME=<YourAccountName> API_ACCESS_ID=<YourAccessID> API_ACCESS_KEY=<'YourAccessKey'>

While Using Bearer Authentication:

export ACCOUNT_NAME=<YourAccountName> API_BEARER_TOKEN=<YourBearerToken>

Read below for understanding more about Models in SDK.

Model

  • Resource
Resource resource = new Resource(Ids,Name,Description,Properties,Create);

Ids(Dictonary<string,string>): An Dictionary of existing resource properties that will be used to identify the resource. See Managing Resources that Ingest Push Metrics for information on the types of properties that can be used. If no resource is matched and the create parameter is set to TRUE, a new resource is created with these specified resource IDs set on it. If the system.displayname and/or system.hostname property is included as resource IDs, they will be used as host name and display name respectively in the resulting resource.

Name(string): Resource unique name. Only considered when creating a new resource.

Properties(Dictonary<string,string>): New properties for resource. Updates to existing resource properties are not considered. Depending on the property name, we will convert these properties into system, auto, or custom properties.

Description(string): Resource description. Only considered when creating a new resource.

Create(bool): Do you want to create the resource.

  • DataSource
DataSource dataSource = new DataSource(DataSourceName,DataSourceGroup,DisplayName,Id );

Name(string): DataSource unique name. Used to match an existing DataSource. If no existing DataSource matches the name provided here, a new DataSource is created with this name.

DisplayName(string): DataSource display name. Only considered when creating a new DataSource.

Group(string): DataSource group name. Only considered when DataSource does not already belong to a group. Used to organize the DataSource within a DataSource group. If no existing DataSource group matches, a new group is created with this name and the DataSource is organized under the new group.

Id(int): DataSource unique ID. Used only to match an existing DataSource. If no existing DataSource matches the provided ID, an error results.

  • DatasourceInstance
DataSourceInstance dataSourceInstance = new DataSourceInstance(Name,DisplayName,Description,Properties);

Name(string): Instance name. If no existing instance matches, a new instance is created with this name.

DisplayName(string): Instance display name. Only considered when creating a new instance.

Properties(Dictionary<string,string>): New properties for instance. Updates to existing instance properties are not considered. Depending on the property name, we will convert these properties into system, auto, or custom properties.

Description(string): Resource description. Only considered when creating a new resource.

  • DataPoint
DataPoint dataPoint = new DataPoint(Name,Description,AggregationType,Description);

Name(string): Datapoint name. If no existing datapoint matches for specified DataSource, a new datapoint is created with this name.

AggreationType(string):The aggregation method, if any, that should be used if data is pushed in sub-minute intervals. Allowed options are “sum”, “average” and “none”(default) where “none” would take last value for that minute. Only considered when creating a new datapoint. See the About the Push Metrics REST API section of this guide for more information on datapoint value aggregation intervals.

Description(string): Datapoint description. Only considered when creating a new datapoint.

Type(string): Metric type as a number in string format. Allowed options are “guage” (default) and “counter”. Only considered when creating a new datapoint.

  • Value
Dictionary<string,string> value = new Dictionary<string,string>();

Value is a dictionary which stores the time of data emittion(in epoch) as Key of dictionary and Metric Data as Value of dictionary.

Documentation for API Endpoints

All URIs are relative to https://AccountName.logicmonitor.com/rest