How to set TimeStamp from java?

Hi,

i am using the elasticsearch-java-Client:

  	<dependency>
      <groupId>co.elastic.clients</groupId>
      <artifactId>elasticsearch-java</artifactId>
      <version>8.2.0</version>
    </dependency>

and connected to a Elastic-Server. Puting documents (we want to log from java) into ES works:

Logentry3 log = new Logentry3.Builder(message, level, this.anwendungsID, this.sessionID).addAll(optionale_Daten).build();
Request request = new Request("POST", indexname);
ObjectMapper mapper = new ObjectMapper(); // Jackson Json
request.setJsonEntity(mapper.writeValueAsString(log));
Response response = ct.restClient.performRequest(request);

ct is just a custom class from us where the connection is done and saved.
Logentry3 is a custom class from us to hold:
String message, log_level status, int anwendungsID, int sessionID and a HashMap<String, Object>() optional_data

Now we want to add time to allow kibana to display Dashboards within a specified begin and endtime. The system.currenttimeMillis() seems not to work for that.

Which Java-class do we need so save within the document?

Thanks

Enomine

I think (but don't know for sure) that while creating a data view on Kibana -> Stack Management -> Data views
i should be able to choose a Timestamp field if i did everything right.
Currently i can not.

Thanks

Enomine

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.