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 Summary
Fields Modifier and Type Field Description static boolean
KEEPALIVE
static String
KEEPALIVE_DEFAULT
static int
KEEPALIVE_INTERVAL
static String
KEEPALIVE_INTERVAL_DEFAULT
static String
KEEPALIVE_INTERVAL_PROPERTY
static String
KEEPALIVE_PROPERTY
-
Constructor Summary
Constructors Constructor Description ElasticsearchLogStorageRetriever(String elasticsearchUrl, boolean disableSslVerifications, org.apache.http.auth.Credentials elasticsearchCredentials, groovy.text.Template buildLogsVisualizationUrlTemplate, TemplateBindingsProvider templateBindingsProvider)
TODO verify username:password auth vs apiKey auth
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description List<FormValidation>
checkElasticsearchSetup()
Example of a successful check:void
close()
LogsQueryResult
overallLog(String jobFullName, int runNumber, String traceId, String spanId, boolean complete, Instant startTime, Instant endTime)
protected static String
prettyPrintPhaseRetentionPolicy(co.elastic.clients.elasticsearch.ilm.Phase phase, String phaseName)
LogsQueryResult
stepLog(String jobFullName, int runNumber, String flowNodeId, String traceId, String spanId, boolean complete, Instant startTime, Instant endTime)
String
toString()
-
-
-
Field Detail
-
KEEPALIVE_INTERVAL_DEFAULT
public static final String KEEPALIVE_INTERVAL_DEFAULT
- See Also:
- Constant Field Values
-
KEEPALIVE_DEFAULT
public static final String KEEPALIVE_DEFAULT
- See Also:
- Constant Field Values
-
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 Detail
-
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 Detail
-
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 interfaceLogStorageRetriever
- Parameters:
jobFullName
- seeAbstractItem.getFullName()
runNumber
- seeRun.getNumber()
complete
- if true, we claim to be serving the complete log for a build, so implementations should be sure to retrieve final log linesstartTime
- Pipeline run start time. SeeRun.getStartTimeInMillis()
endTime
-null
if the pipeline is still running. SeeRun.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 interfaceLogStorageRetriever
- Parameters:
jobFullName
- seeAbstractItem.getFullName()
runNumber
- seeRun.getNumber()
flowNodeId
- seeFlowNode.getId()
complete
- if true, we claim to be serving the complete log for a build, so implementations should be sure to retrieve final log linesstartTime
- Pipeline run start time. SeeRun.getStartTimeInMillis()
endTime
-null
if the pipeline is still running. SeeRun.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 interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
-