Skip to content
This repository has been archived by the owner on Nov 9, 2020. It is now read-only.

Java API to communicate with LogInsight REST interfaces

License

Notifications You must be signed in to change notification settings

vmware-archive/loginsight-java-api

Repository files navigation

VMware has ended active development of this project, this repository will no longer be updated.

Maven Central Gitter Javadocs Build Status Coverage Status [//]: javadoc

loginsight-java-api

VMware vRealize LogInsight provides a REST API. For more information on REST API, refer to Steve Flanders blog post Log Insight 3.3: Query API

We are providing an easy to use java wrapper to interact with VMware vRealize LogInsight. This loginsight-java-api currently supports

  • message queries
  • aggregate queries and
  • ingesion

Join us @gitter to discuss on any issues on using this API.

Usage

Getting the jar

Functionality of this package is contained in Java package com.vmware.loginsightapi. To use the package, you need to use following Maven dependency:

<dependency>
    <groupId>com.vmware.loginsightapi</groupId>
    <artifactId>loginsight-java-api</artifactId>
    <version>0.1.1</version>
</dependency>

In case of gradle project please use the following

compile group: 'com.vmware.loginsightapi', name: 'loginsight-java-api', version: '0.1.1'

API

####1. Connecting to LogInsight

LogInsightClient client = new LogInsightClient("host-name", "username", "password");

####2. Ingestion of messages to LogInsight

IngestionRequest request = new IngestionRequestBuilder()
	.message(new Message("message line 1"))
	.message(new MessageBuilder("message line 2")
	.field("field1", "content 1").build())
	.build();
CompletableFuture<IngestionResponse> responseFuture = client.ingest(request);

####3. Event Queries

MessageQuery mqb = (MessageQuery) new MessageQuery()
	.addConstraint("field_1", FieldConstraint.Operator.EQ, "value1")
	.addContentPackField("test");
CompletableFuture<MessageQueryResponse> responseFuture = client.messageQuery(mqb.toUrlString());

####4. Aggregation Queries

Default aggregation function is COUNT as defined by LogInsight API.

AggregateQuery aqb = (AggregateQuery) new AggregateQuery()
	.addConstraint("field_1", FieldConstraint.Operator.EQ,"value1")
	.addContentPackField("test");
CompletableFuture<AggregateQueryResponse> responseFuture = client.aggregateQuery(aqb.toUrlString());

Build from source

Prerequisites

  • Java 8 JDK installed and set your JAVA_HOME to home of Java8 JDK
  • vRealize LogInsight 3.3 onwards

Build & Run

$ ./gradlew clean build

Contributing

The loginsight-java-api project team welcomes contributions from the community. If you wish to contribute code and you have not signed our contributor license agreement (CLA), our bot will update the issue when you open a Pull Request. For any questions about the CLA process, please refer to our FAQ. For more detailed information, refer to CONTRIBUTING.md.

License

Copyright © 2016 VMware, Inc. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

Some files may be comprised of various open source software components, each of which has its own license that is located in the source code of the respective component.