Class ElasticsearchLogStorageRetriever

java.lang.Object
io.jenkins.plugins.opentelemetry.backend.elastic.ElasticsearchLogStorageRetriever
All Implemented Interfaces:
LogStorageRetriever, Closeable, AutoCloseable

public class ElasticsearchLogStorageRetriever extends Object implements LogStorageRetriever, Closeable
Retrieve the logs from Elasticsearch.
  • Field Details

    • KEEPALIVE_INTERVAL_DEFAULT

      public static final String KEEPALIVE_INTERVAL_DEFAULT
      See Also:
    • KEEPALIVE_DEFAULT

      public static final String KEEPALIVE_DEFAULT
      See Also:
    • KEEPALIVE_INTERVAL_PROPERTY

      public static final String KEEPALIVE_INTERVAL_PROPERTY
    • KEEPALIVE_PROPERTY

      public static final String KEEPALIVE_PROPERTY
    • KEEPALIVE_INTERVAL

      public static final int KEEPALIVE_INTERVAL
    • KEEPALIVE

      public static final boolean KEEPALIVE
  • Constructor Details

    • ElasticsearchLogStorageRetriever

      @MustBeClosed public ElasticsearchLogStorageRetriever(@NonNull String elasticsearchUrl, boolean disableSslVerifications, @NonNull org.apache.http.auth.Credentials elasticsearchCredentials, @NonNull groovy.text.Template buildLogsVisualizationUrlTemplate, @NonNull TemplateBindingsProvider templateBindingsProvider)
      TODO verify username:password auth vs apiKey auth
  • Method Details

    • overallLog

      @NonNull public LogsQueryResult overallLog(@NonNull String jobFullName, int runNumber, @NonNull String traceId, @NonNull String spanId, boolean complete, @NonNull Instant startTime, Instant endTime)
      Specified by:
      overallLog in interface LogStorageRetriever
      Parameters:
      jobFullName - see AbstractItem.getFullName()
      runNumber - see Run.getNumber()
      complete - if true, we claim to be serving the complete log for a build, so implementations should be sure to retrieve final log lines
      startTime - Pipeline run start time. See Run.getStartTimeInMillis()
      endTime - null if the pipeline is still running. See Run.getDuration()
    • stepLog

      @NonNull public LogsQueryResult stepLog(@NonNull String jobFullName, int runNumber, @NonNull String flowNodeId, @NonNull String traceId, @NonNull String spanId, boolean complete, @NonNull Instant startTime, @Nullable Instant endTime)
      Specified by:
      stepLog in interface LogStorageRetriever
      Parameters:
      jobFullName - see AbstractItem.getFullName()
      runNumber - see Run.getNumber()
      flowNodeId - see FlowNode.getId()
      complete - if true, we claim to be serving the complete log for a build, so implementations should be sure to retrieve final log lines
      startTime - Pipeline run start time. See Run.getStartTimeInMillis()
      endTime - null if the pipeline is still running. See Run.getDuration()
    • checkElasticsearchSetup

      public List<FormValidation> checkElasticsearchSetup()
      Example of a successful check:
      
       OK: Verify existence of the Elasticsearch Index Template 'logs-apm.app' used to store Jenkins pipeline logs...
       OK: Connected to Elasticsearch https://***.es.example.com with user 'jenkins'.
       OK: Index Template 'logs-apm.app' found.
       OK: Verify existence of the Index Lifecycle Management (ILM) Policy 'logs-apm.app' associated with the Index Template 'logs-apm.app' to define the time to live of the Jenkins pipeline logs in Elasticsearch...
       OK: Index Lifecycle Policy 'logs-apm.app_logs-default_policy' found.
       OK: Logs retention policy: hot[rollover[maxAge=30d, maxSize=50gb]], warm [phase not defined], cold [phase not defined], delete[delete[min_age=10d]].
       
    • prettyPrintPhaseRetentionPolicy

      @NonNull protected static String prettyPrintPhaseRetentionPolicy(co.elastic.clients.elasticsearch.ilm.Phase phase, String phaseName)
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • toString

      public String toString()
      Overrides:
      toString in class Object