LogicMonitor Log Ingestion Java SDK.
NOTE: This SDK was created for use by LogicMonitor-built log integrations and is not intended to be used or supported otherwise.
Building the API client library requires:
- Java 9+
- Maven/Gradle
Add this dependency to your project's POM:
<dependency>
<groupId>com.logicmonitor</groupId>
<artifactId>lm-logs-sdk-java</artifactId>
<version>1.2</version>
<scope>compile</scope>
</dependency>
Add this dependency to your project's build file:
compile "com.logicmonitor:lm-logs-sdk-java:1.2"
At first generate the JAR by executing:
mvn clean package
Then manually install the following JARs:
target/lm-logs-sdk-java-1.2.jar
target/lib/*.jar
import java.util.Arrays;
import java.util.List;
import com.logicmonitor.logs.LMLogsApi;
import com.logicmonitor.logs.LMLogsApiException;
import com.logicmonitor.logs.LMLogsApiResponse;
import com.logicmonitor.logs.model.LogEntry;
public class LogIngestApiExample {
public static void main(String[] args) {
LMLogsApi apiInstance = new LMLogsApi.Builder()
.withCompany("your_company")
.withAccessId("LM_access_id")
.withAccessKey("LM_token_id")
.withUserAgentHeader("<platform>/<version>")
.build();
LogEntry entry = new LogEntry()
.message("log_message")
.putLmResourceIdItem("resource_id_key", "resource_id_value");
List<LogEntry> logEntries = Arrays.asList(entry);
LMLogsApiResponse<?> response;
try {
response = apiInstance.logIngestPostWithHttpInfo(logEntries);
} catch (LMLogsApiException e) {
e.printStackTrace();
response = e.getResponse();
}
System.out.println("Request ID: " + response.getRequestId());
System.out.println("Status code: " + response.getStatusCode());
System.out.println("Body: " + response.getData());
}
}