-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from logicmonitor/validation-fix
Updated example and fixed authentication bug
- Loading branch information
Showing
3 changed files
with
54 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,25 @@ | ||
|
||
import logging | ||
# Sample Program to send Logs to LogicMonitor Platform | ||
# | ||
import os | ||
import time | ||
|
||
import psutil as psutil | ||
|
||
import logicmonitor_data_sdk | ||
|
||
from logicmonitor_data_sdk.api.logs import Logs | ||
from logicmonitor_data_sdk.models import Resource | ||
|
||
logger = logging.getLogger('lmdata.api') | ||
logger.setLevel(logging.INFO) | ||
# Initialize LM SDK and provide required authentication parameters | ||
# On LM Portal, create 'API Token' for the user to get access Id and access Key | ||
configuration = logicmonitor_data_sdk.Configuration( company='your_company', | ||
id='API access id', | ||
key='API access key') | ||
|
||
configuration = logicmonitor_data_sdk.Configuration(company='yourcompany', | ||
id='accessID', | ||
key='accessKey') | ||
|
||
# The resource which is already present on LM Platform. Use a unique property to match | ||
# the resource and send log for that. | ||
resource = Resource(ids={"system.hostname": 'your_system'}) | ||
|
||
resource = Resource(ids={"System.hostname": "192.168.1.33"}) | ||
#Create an api handle for sending the logs | ||
# "batch" would club logs for 8MB size or 30 Sec - whichever is earlier. Its default is "True". | ||
log_api = Logs(batch = False) | ||
log_api.send_logs(resource = resource,msg= "this is smaple log") | ||
|
||
|
||
|
||
|
||
|
||
return_value = log_api.send_logs(resource=resource, msg= "this is sample log") | ||
|
||
print(return_value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters