This is an automated email from the ASF dual-hosted git repository.
wankai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking.git
The following commit(s) were added to refs/heads/master by this push:
new 90d5006e89 Support tracing logs query for debugging and add banyandb
case for logs e2e. (#12424)
90d5006e89 is described below
commit 90d5006e8925a39a87eb2279b29989907b86a052
Author: Wan Kai <[email protected]>
AuthorDate: Tue Jul 9 14:59:11 2024 +0800
Support tracing logs query for debugging and add banyandb case for logs
e2e. (#12424)
---
.github/workflows/skywalking.yaml | 2 +
docs/en/api/query-protocol.md | 2 +-
docs/en/changes/changes.md | 1 +
docs/en/debugging/query-tracing.md | 64 +++++++++++++++++-
.../oap/server/core/query/LogQueryService.java | 44 ++++++++++++-
.../oap/server/core/query/TraceQueryService.java | 1 +
.../server/core/query/input/LogQueryCondition.java | 2 +
.../core/query/input/TraceScopeCondition.java | 2 +
.../oap/server/core/query/type/Logs.java | 2 +
.../server/core/storage/query/ILogQueryDAO.java | 45 +++++++++++++
.../oap/query/debug/DebuggingHTTPHandler.java | 76 ++++++++++++++++++++++
.../query/debug/log/DebuggingQueryLogsRsp.java} | 27 +++-----
.../oap/query/graphql/resolver/LogQuery.java | 22 ++++++-
.../src/main/resources/query-protocol | 2 +-
.../banyandb/stream/BanyanDBLogQueryDAO.java | 2 +-
.../plugin/elasticsearch/query/LogQueryEsDAO.java | 2 +-
test/e2e-v2/cases/log/banyandb/docker-compose.yml | 53 +++++++++++++++
test/e2e-v2/cases/log/banyandb/e2e.yaml | 47 +++++++++++++
18 files changed, 371 insertions(+), 25 deletions(-)
diff --git a/.github/workflows/skywalking.yaml
b/.github/workflows/skywalking.yaml
index bc0cfe9b15..42e97bbb0c 100644
--- a/.github/workflows/skywalking.yaml
+++ b/.github/workflows/skywalking.yaml
@@ -434,6 +434,8 @@ jobs:
- name: Log ES 8.8.1 Shardng
config: test/e2e-v2/cases/log/es/es-sharding/e2e.yaml
env: ES_VERSION=8.8.1
+ - name: Log BanyanDB
+ config: test/e2e-v2/cases/log/banyandb/e2e.yaml
- name: Log FluentBit ES 7.16.3
config: test/e2e-v2/cases/log/fluent-bit/e2e.yaml
diff --git a/docs/en/api/query-protocol.md b/docs/en/api/query-protocol.md
index 8f5936ea2b..6194609e1c 100644
--- a/docs/en/api/query-protocol.md
+++ b/docs/en/api/query-protocol.md
@@ -133,7 +133,7 @@ enum ExpressionResultType {
extend type Query {
# Return true if the current storage implementation supports fuzzy query
for logs.
supportQueryLogsByKeywords: Boolean!
- queryLogs(condition: LogQueryCondition): Logs
+ queryLogs(condition: LogQueryCondition, debug: Boolean): Logs
# Test the logs and get the results of the LAL output.
test(requests: LogTestRequest!): LogTestResponse!
# Read the list of searchable keys
diff --git a/docs/en/changes/changes.md b/docs/en/changes/changes.md
index f7ba11e34c..ccaf6f1023 100644
--- a/docs/en/changes/changes.md
+++ b/docs/en/changes/changes.md
@@ -29,6 +29,7 @@
* Polish BanyanDB group and schema creation logic to fix the schema creation
failure issue in distributed race conditions.
* Support tracing topology query for debugging.
* Fix expression of graph `Current QPS` in MySQL dashboard.
+* Support tracing logs query for debugging.
#### UI
* Highlight search log keywords.
diff --git a/docs/en/debugging/query-tracing.md
b/docs/en/debugging/query-tracing.md
index 065ec02853..300e9fb674 100644
--- a/docs/en/debugging/query-tracing.md
+++ b/docs/en/debugging/query-tracing.md
@@ -425,7 +425,6 @@ debuggingTrace:
- Example
```shell
-
curl -X GET
'http://127.0.0.1:12800/debugging/query/topology/getProcessTopology?startTime=2024-07-03&endTime=2024-07-03&step=DAY&service=mock_a_service&serviceLayer=GENERAL&instance=mock_a_service_instance'
```
@@ -440,6 +439,45 @@ debuggingTrace:
...
```
+### Tracing Log Query
+
+#### Tracing SkyWalking API queryLogs
+ URL: HTTP GET `http://{core restHost}:{core
restPort}/debugging/query/log/queryLogs?{parameters}`.
+ Parameters
+
+ | Field | Description
| Required |
+
|----------------------------|----------------------------------------------------------------|--------------------------------|
+ | startTime | The start time of the query
| Yes, unless traceId not empty |
+ | endTime | The end time of the query
| Yes, unless traceId not empty |
+ | step | The query step
| Yes, unless traceId not empty |
+ | service | The service name
| No, require serviceLayer |
+ | serviceLayer | The service layer name
| No |
+ | serviceInstance | The service instance name
| No, require service |
+ | endpoint | The endpoint name
| No, require service |
+ | traceId | The trace ID
| No |
+ | segmentId | The segment ID
| No, require traceId |
+ | spanId | The span ID
| No, require traceId |
+ | queryOrder | The order of the query result, `ASC`, `DES`
| No, default `DES` |
+ | tags | The tags of the trace,
`key1=value1,key2=value2` | No |
+ | pageNum | The page number of the query result
| Yes |
+ | pageSize | The page size of the query result
| Yes |
+ | keywordsOfContent | The keywords of the log content,
`keyword1,keyword2` | No |
+ | excludingKeywordsOfContent | The excluding keywords of the log content,
`keyword1,keyword2` | No |
+
+- Example
+```shell
+curl -X GET
'http://127.0.0.1:12800/debugging/query/log/queryLogs?service=e2e-service-provider&serviceLayer=GENERAL&startTime=2024-07-09&endTime=2024-07-09&step=DAY&pageNum=1&pageSize=15&queryOrder=ASC&tags=level%3DINFO'
+```
+
+Response will include query result and the debuggingTrace information, the
debuggingTrace information is the same as the MQE query tracing:
+
+```yaml
+logs:
+...
+debuggingTrace:
+...
+```
+
## Debugging with GraphQL bundled
When querying the metrics though the [GraphQL APIs](../api/query-protocol.md),
the query tracing service is also provided within the GraphQL bundled.
@@ -717,3 +755,27 @@ type ProcessTopology {
- Example
Same as the MQE query tracing, follow the GraphQL protocol and grammar to
query the result and get debuggingTrace information,
just enable the debug parameter to true.
+
+### Tracing Log Query
+- Bundle API: [Log](../api/query-protocol.md#logs)
+
+```graphql
+extend type Query {
+...
+ queryLogs(condition: LogQueryCondition, debug: Boolean): Logs
+...
+}
+```
+
+```graphql
+type Logs {
+ # When this field is not empty, frontend should display it in UI
+ errorReason: String
+ logs: [Log!]!
+ debuggingTrace: DebuggingTrace
+}
+```
+
+- Example
+Same as the MQE query tracing, follow the GraphQL protocol and grammar to
query the result and get debuggingTrace information,
+just enable the debug parameter to true.
diff --git
a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/LogQueryService.java
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/LogQueryService.java
index fc93944c21..6ed55d4554 100644
---
a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/LogQueryService.java
+++
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/LogQueryService.java
@@ -22,6 +22,8 @@ import java.io.IOException;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.skywalking.oap.server.core.query.input.Duration;
+import
org.apache.skywalking.oap.server.core.query.type.debugging.DebuggingSpan;
+import
org.apache.skywalking.oap.server.core.query.type.debugging.DebuggingTraceContext;
import org.apache.skywalking.oap.server.library.util.StringUtil;
import org.apache.skywalking.oap.server.core.analysis.IDManager;
import org.apache.skywalking.oap.server.core.analysis.manual.searchtag.Tag;
@@ -35,6 +37,7 @@ import
org.apache.skywalking.oap.server.library.module.ModuleManager;
import org.apache.skywalking.oap.server.library.module.Service;
import static java.util.Objects.nonNull;
+import static
org.apache.skywalking.oap.server.core.query.type.debugging.DebuggingTraceContext.TRACE_CONTEXT;
public class LogQueryService implements Service {
@@ -66,6 +69,45 @@ public class LogQueryService implements Service {
final List<Tag> tags,
List<String> keywordsOfContent,
List<String> excludingKeywordsOfContent) throws
IOException {
+ DebuggingTraceContext traceContext = TRACE_CONTEXT.get();
+ DebuggingSpan span = null;
+ try {
+ if (traceContext != null) {
+ StringBuilder msg = new StringBuilder();
+ span = traceContext.createSpan("Query Service: queryLogs");
+ msg.append("ServiceId: ").append(serviceId).append(", ");
+ msg.append("ServiceInstanceId:
").append(serviceInstanceId).append(", ");
+ msg.append("EndpointId: ").append(endpointId).append(", ");
+ msg.append("RelatedTrace: ").append(relatedTrace).append(", ");
+ msg.append("Pagination: ").append(paging).append(", ");
+ msg.append("QueryOrder: ").append(queryOrder).append(", ");
+ msg.append("Duration: ").append(duration).append(", ");
+ msg.append("Tags: ").append(tags).append(", ");
+ msg.append("KeywordsOfContent:
").append(keywordsOfContent).append(", ");
+ msg.append("ExcludingKeywordsOfContent:
").append(excludingKeywordsOfContent);
+ span.setMsg(msg.toString());
+ }
+ return invokeQueryLogs(
+ serviceId, serviceInstanceId, endpointId, relatedTrace,
paging, queryOrder, duration, tags,
+ keywordsOfContent, excludingKeywordsOfContent
+ );
+ } finally {
+ if (traceContext != null) {
+ traceContext.stopSpan(span);
+ }
+ }
+ }
+
+ private Logs invokeQueryLogs(String serviceId,
+ String serviceInstanceId,
+ String endpointId,
+ TraceScopeCondition relatedTrace,
+ Pagination paging,
+ Order queryOrder,
+ final Duration duration,
+ final List<Tag> tags,
+ List<String> keywordsOfContent,
+ List<String> excludingKeywordsOfContent) throws
IOException {
PaginationUtils.Page page = PaginationUtils.INSTANCE.exchange(paging);
if (nonNull(keywordsOfContent)) {
@@ -79,7 +121,7 @@ public class LogQueryService implements Service {
.collect(Collectors.toList());
}
- Logs logs = getLogQueryDAO().queryLogs(serviceId,
+ Logs logs = getLogQueryDAO().queryLogsDebuggable(serviceId,
serviceInstanceId,
endpointId,
relatedTrace,
diff --git
a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/TraceQueryService.java
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/TraceQueryService.java
index 470812b596..b1be54ea19 100644
---
a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/TraceQueryService.java
+++
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/TraceQueryService.java
@@ -150,6 +150,7 @@ public class TraceQueryService implements Service {
StringBuilder msg = new StringBuilder();
span = traceContext.createSpan("Query Service: queryTrace");
msg.append("Condition: TraceId: ").append(traceId);
+ span.setMsg(msg.toString());
}
return invokeQueryTrace(traceId);
} finally {
diff --git
a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/input/LogQueryCondition.java
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/input/LogQueryCondition.java
index 8b5f31c90e..1f848f1cf8 100644
---
a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/input/LogQueryCondition.java
+++
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/input/LogQueryCondition.java
@@ -21,12 +21,14 @@ package org.apache.skywalking.oap.server.core.query.input;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
+import lombok.ToString;
import org.apache.skywalking.oap.server.core.analysis.manual.searchtag.Tag;
import org.apache.skywalking.oap.server.core.query.enumeration.Order;
import org.apache.skywalking.oap.server.core.query.type.Pagination;
@Getter
@Setter
+@ToString
public class LogQueryCondition {
private String serviceId;
private String serviceInstanceId;
diff --git
a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/input/TraceScopeCondition.java
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/input/TraceScopeCondition.java
index 995d5af4bc..b5b2aecc30 100644
---
a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/input/TraceScopeCondition.java
+++
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/input/TraceScopeCondition.java
@@ -19,9 +19,11 @@ package org.apache.skywalking.oap.server.core.query.input;
import lombok.Getter;
import lombok.Setter;
+import lombok.ToString;
@Setter
@Getter
+@ToString
public class TraceScopeCondition {
private String traceId;
diff --git
a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/type/Logs.java
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/type/Logs.java
index 523e0a69fe..ea8253050f 100644
---
a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/type/Logs.java
+++
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/type/Logs.java
@@ -24,6 +24,7 @@ import lombok.experimental.Accessors;
import java.util.ArrayList;
import java.util.List;
+import
org.apache.skywalking.oap.server.core.query.type.debugging.DebuggingTrace;
@Setter
@Getter
@@ -31,6 +32,7 @@ import java.util.List;
public class Logs {
private final List<Log> logs;
private String errorReason;
+ private DebuggingTrace debuggingTrace;
public Logs() {
this.logs = new ArrayList<>();
diff --git
a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/ILogQueryDAO.java
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/ILogQueryDAO.java
index 3e412d5178..fc2f0e56ee 100644
---
a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/ILogQueryDAO.java
+++
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/ILogQueryDAO.java
@@ -31,14 +31,59 @@ import
org.apache.skywalking.oap.server.core.query.input.Duration;
import org.apache.skywalking.oap.server.core.query.input.TraceScopeCondition;
import org.apache.skywalking.oap.server.core.query.type.KeyValue;
import org.apache.skywalking.oap.server.core.query.type.Logs;
+import
org.apache.skywalking.oap.server.core.query.type.debugging.DebuggingSpan;
+import
org.apache.skywalking.oap.server.core.query.type.debugging.DebuggingTraceContext;
import org.apache.skywalking.oap.server.library.module.Service;
+import static
org.apache.skywalking.oap.server.core.query.type.debugging.DebuggingTraceContext.TRACE_CONTEXT;
+
public interface ILogQueryDAO extends Service {
default boolean supportQueryLogsByKeywords() {
return false;
}
+ default Logs queryLogsDebuggable(String serviceId,
+ String serviceInstanceId,
+ String endpointId,
+ TraceScopeCondition relatedTrace,
+ Order queryOrder,
+ int from,
+ int limit,
+ final Duration duration,
+ final List<Tag> tags,
+ final List<String> keywordsOfContent,
+ final List<String>
excludingKeywordsOfContent) throws IOException {
+ DebuggingTraceContext traceContext = TRACE_CONTEXT.get();
+ DebuggingSpan span = null;
+ try {
+ if (traceContext != null) {
+ span = traceContext.createSpan("Query Dao: queryLogs");
+ StringBuilder msg = new StringBuilder();
+ msg.append("ServiceId: ").append(serviceId)
+ .append(", ServiceInstanceId: ").append(serviceInstanceId)
+ .append(", EndpointId: ").append(endpointId)
+ .append(", RelatedTrace: ").append(relatedTrace)
+ .append(", QueryOrder: ").append(queryOrder)
+ .append(", From: ").append(from)
+ .append(", Limit: ").append(limit)
+ .append(", Duration: ").append(duration)
+ .append(", Tags: ").append(tags)
+ .append(", KeywordsOfContent: ").append(keywordsOfContent)
+ .append(", ExcludingKeywordsOfContent:
").append(excludingKeywordsOfContent);
+ span.setMsg(msg.toString());
+ }
+ return queryLogs(
+ serviceId, serviceInstanceId, endpointId, relatedTrace,
queryOrder, from, limit, duration, tags,
+ keywordsOfContent, excludingKeywordsOfContent
+ );
+ } finally {
+ if (traceContext != null && span != null) {
+ traceContext.stopSpan(span);
+ }
+ }
+ }
+
Logs queryLogs(String serviceId,
String serviceInstanceId,
String endpointId,
diff --git
a/oap-server/server-query-plugin/debugging-query-plugin/src/main/java/org/apache/skywalking/oap/query/debug/DebuggingHTTPHandler.java
b/oap-server/server-query-plugin/debugging-query-plugin/src/main/java/org/apache/skywalking/oap/query/debug/DebuggingHTTPHandler.java
index 4e8b8c1982..50797750c2 100644
---
a/oap-server/server-query-plugin/debugging-query-plugin/src/main/java/org/apache/skywalking/oap/query/debug/DebuggingHTTPHandler.java
+++
b/oap-server/server-query-plugin/debugging-query-plugin/src/main/java/org/apache/skywalking/oap/query/debug/DebuggingHTTPHandler.java
@@ -39,6 +39,7 @@ import java.util.stream.Collectors;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.skywalking.mqe.rt.type.ExpressionResult;
+import org.apache.skywalking.oap.query.debug.log.DebuggingQueryLogsRsp;
import org.apache.skywalking.oap.query.debug.mqe.DebuggingMQERsp;
import
org.apache.skywalking.oap.query.debug.topology.DebuggingQueryEndpointTopologyRsp;
import
org.apache.skywalking.oap.query.debug.topology.DebuggingQueryInstanceTopologyRsp;
@@ -48,6 +49,7 @@ import
org.apache.skywalking.oap.query.debug.trace.DebuggingQueryTraceBriefRsp;
import org.apache.skywalking.oap.query.debug.trace.DebuggingQueryTraceRsp;
import
org.apache.skywalking.oap.query.debug.trace.zipkin.DebuggingZipkinQueryTraceRsp;
import
org.apache.skywalking.oap.query.debug.trace.zipkin.DebuggingZipkinQueryTracesRsp;
+import org.apache.skywalking.oap.query.graphql.resolver.LogQuery;
import org.apache.skywalking.oap.query.graphql.resolver.MetricsExpressionQuery;
import org.apache.skywalking.oap.query.graphql.resolver.TopologyQuery;
import org.apache.skywalking.oap.query.graphql.resolver.TraceQuery;
@@ -58,11 +60,15 @@ import org.apache.skywalking.oap.server.core.CoreModule;
import org.apache.skywalking.oap.server.core.analysis.IDManager;
import org.apache.skywalking.oap.server.core.analysis.Layer;
import org.apache.skywalking.oap.server.core.analysis.manual.searchtag.Tag;
+import org.apache.skywalking.oap.server.core.query.enumeration.Order;
import org.apache.skywalking.oap.server.core.query.enumeration.Step;
import org.apache.skywalking.oap.server.core.query.input.Duration;
import org.apache.skywalking.oap.server.core.query.input.Entity;
+import org.apache.skywalking.oap.server.core.query.input.LogQueryCondition;
import org.apache.skywalking.oap.server.core.query.input.TraceQueryCondition;
+import org.apache.skywalking.oap.server.core.query.input.TraceScopeCondition;
import org.apache.skywalking.oap.server.core.query.type.EndpointTopology;
+import org.apache.skywalking.oap.server.core.query.type.Logs;
import org.apache.skywalking.oap.server.core.query.type.Pagination;
import org.apache.skywalking.oap.server.core.query.type.ProcessTopology;
import org.apache.skywalking.oap.server.core.query.type.QueryOrder;
@@ -86,6 +92,7 @@ public class DebuggingHTTPHandler {
private final TraceQuery traceQuery;
private final ZipkinQueryHandler zipkinQueryHandler;
private final TopologyQuery topologyQuery;
+ private final LogQuery logQuery;
final DebuggingQueryConfig config;
public DebuggingHTTPHandler(final ModuleManager manager, final
DebuggingQueryConfig config) {
@@ -98,6 +105,7 @@ public class DebuggingHTTPHandler {
//use zipkin default config for debugging
this.zipkinQueryHandler = new ZipkinQueryHandler(new
ZipkinQueryConfig(), manager);
this.topologyQuery = new TopologyQuery(manager);
+ this.logQuery = new LogQuery(manager);
}
@Get("/debugging/config/dump")
@@ -377,6 +385,74 @@ public class DebuggingHTTPHandler {
return transToYAMLString(result);
}
+ @SneakyThrows
+ @Get("/debugging/query/log/queryLogs")
+ public String queryLogs(@Param("service") Optional<String> service,
+ @Param("serviceLayer") Optional<String>
serviceLayer,
+ @Param("serviceInstance") Optional<String>
serviceInstance,
+ @Param("endpoint") Optional<String> endpoint,
+ @Param("startTime") Optional<String> startTime,
+ @Param("endTime") Optional<String> endTime,
+ @Param("step") Optional<String> step,
+ @Param("traceId") Optional<String> traceId,
+ @Param("segmentId") Optional<String> segmentId,
+ @Param("spanId") Optional<Integer> spanId,
+ @Param("tags") Optional<String> tags,
+ @Param("pageNum") int pageNum,
+ @Param("pageSize") int pageSize,
+ @Param("keywordsOfContent") Optional<String>
keywordsOfContent,
+ @Param("excludingKeywordsOfContent")
Optional<String> excludingKeywordsOfContent,
+ @Param("queryOrder") Optional<String> queryOrder) {
+ LogQueryCondition condition = new LogQueryCondition();
+ condition.setPaging(new Pagination(pageNum, pageSize));
+ if (traceId.isPresent()) {
+ TraceScopeCondition traceScopeCondition = new
TraceScopeCondition();
+ traceScopeCondition.setTraceId(traceId.get());
+ segmentId.ifPresent(traceScopeCondition::setSegmentId);
+ spanId.ifPresent(traceScopeCondition::setSpanId);
+ condition.setRelatedTrace(traceScopeCondition);
+ } else {
+ if (startTime.isEmpty() || endTime.isEmpty() || step.isEmpty()) {
+ return "startTime, endTime and step are required";
+ }
+ Duration duration = new Duration();
+ duration.setStart(startTime.get());
+ duration.setEnd(endTime.get());
+ duration.setStep(Step.valueOf(step.get()));
+ condition.setQueryDuration(duration);
+ }
+
+ Optional<String> serviceId = service.map(
+ name -> IDManager.ServiceID.buildId(name,
Layer.nameOf(serviceLayer.orElseThrow()).isNormal()));
+ Optional<String> serviceInstanceId = serviceInstance.map(
+ name ->
IDManager.ServiceInstanceID.buildId(serviceId.orElseThrow(), name));
+ Optional<String> endpointId = endpoint.map(name ->
IDManager.EndpointID.buildId(serviceId.orElseThrow(), name));
+ serviceId.ifPresent(condition::setServiceId);
+ serviceInstanceId.ifPresent(condition::setServiceInstanceId);
+ endpointId.ifPresent(condition::setEndpointId);
+ tags.ifPresent(ts -> {
+ List<Tag> tagList = new ArrayList<>();
+ Arrays.stream(ts.split(Const.COMMA)).forEach(t -> {
+ Tag tag = new Tag();
+ String[] tagArr = t.split(Const.EQUAL);
+ tag.setKey(tagArr[0]);
+ tag.setValue(tagArr[1]);
+ tagList.add(tag);
+ });
+ condition.setTags(tagList);
+ });
+ queryOrder.ifPresent(s -> condition.setQueryOrder(Order.valueOf(s)));
+ keywordsOfContent.ifPresent(
+ k ->
condition.setKeywordsOfContent(Arrays.stream(k.split(Const.COMMA)).collect(Collectors.toList())));
+ excludingKeywordsOfContent.ifPresent(e ->
condition.setExcludingKeywordsOfContent(
+ Arrays.stream(e.split(Const.COMMA)).collect(Collectors.toList())));
+
+ Logs logs = logQuery.queryLogs(condition, true);
+ DebuggingQueryLogsRsp result = new DebuggingQueryLogsRsp(
+ logs.getLogs(), logs.getErrorReason(),
transformTrace(logs.getDebuggingTrace()));
+ return transToYAMLString(result);
+ }
+
private DebuggingTraceRsp transformTrace(DebuggingTrace trace) {
Map<Integer, DebuggingSpanRsp> spanMap = trace.getSpans().stream()
.collect(Collectors.toMap(
diff --git
a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/type/Logs.java
b/oap-server/server-query-plugin/debugging-query-plugin/src/main/java/org/apache/skywalking/oap/query/debug/log/DebuggingQueryLogsRsp.java
similarity index 70%
copy from
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/type/Logs.java
copy to
oap-server/server-query-plugin/debugging-query-plugin/src/main/java/org/apache/skywalking/oap/query/debug/log/DebuggingQueryLogsRsp.java
index 523e0a69fe..e869342309 100644
---
a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/type/Logs.java
+++
b/oap-server/server-query-plugin/debugging-query-plugin/src/main/java/org/apache/skywalking/oap/query/debug/log/DebuggingQueryLogsRsp.java
@@ -16,27 +16,18 @@
*
*/
-package org.apache.skywalking.oap.server.core.query.type;
+package org.apache.skywalking.oap.query.debug.log;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.experimental.Accessors;
-
-import java.util.ArrayList;
import java.util.List;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import org.apache.skywalking.oap.query.debug.DebuggingTraceRsp;
+import org.apache.skywalking.oap.server.core.query.type.Log;
-@Setter
+@RequiredArgsConstructor
@Getter
-@Accessors(chain = true)
-public class Logs {
+public class DebuggingQueryLogsRsp {
private final List<Log> logs;
- private String errorReason;
-
- public Logs() {
- this.logs = new ArrayList<>();
- }
-
- public Logs(final List<Log> logs) {
- this.logs = logs;
- }
+ private final String errorReason;
+ private final DebuggingTraceRsp debuggingTrace;
}
diff --git
a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/LogQuery.java
b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/LogQuery.java
index c45a617f8a..a551ade7ed 100644
---
a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/LogQuery.java
+++
b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/LogQuery.java
@@ -30,11 +30,14 @@ import
org.apache.skywalking.oap.server.core.query.enumeration.Order;
import org.apache.skywalking.oap.server.core.query.input.Duration;
import org.apache.skywalking.oap.server.core.query.input.LogQueryCondition;
import org.apache.skywalking.oap.server.core.query.type.Logs;
+import
org.apache.skywalking.oap.server.core.query.type.debugging.DebuggingSpan;
+import
org.apache.skywalking.oap.server.core.query.type.debugging.DebuggingTraceContext;
import org.apache.skywalking.oap.server.library.module.ModuleManager;
import org.apache.skywalking.oap.server.library.util.CollectionUtils;
import org.apache.skywalking.oap.server.library.util.StringUtil;
import static java.util.Objects.isNull;
+import static
org.apache.skywalking.oap.server.core.query.type.debugging.DebuggingTraceContext.TRACE_CONTEXT;
public class LogQuery implements GraphQLQueryResolver {
private final ModuleManager moduleManager;
@@ -63,7 +66,24 @@ public class LogQuery implements GraphQLQueryResolver {
return getQueryService().supportQueryLogsByKeywords();
}
- public Logs queryLogs(LogQueryCondition condition) throws IOException {
+ public Logs queryLogs(LogQueryCondition condition, boolean debug) throws
IOException {
+ DebuggingTraceContext traceContext = new
DebuggingTraceContext("LogQueryCondition: " + condition, debug, false);
+ DebuggingTraceContext.TRACE_CONTEXT.set(traceContext);
+ DebuggingSpan span = traceContext.createSpan("Query logs");
+ try {
+ Logs logs = invokeQueryLogs(condition);
+ if (debug) {
+ logs.setDebuggingTrace(traceContext.getExecTrace());
+ }
+ return logs;
+ } finally {
+ traceContext.stopSpan(span);
+ traceContext.stopTrace();
+ TRACE_CONTEXT.remove();
+ }
+ }
+
+ private Logs invokeQueryLogs(LogQueryCondition condition) throws
IOException {
if (isNull(condition.getQueryDuration()) &&
isNull(condition.getRelatedTrace())) {
throw new UnexpectedException("The condition must contains either
queryDuration or relatedTrace.");
}
diff --git
a/oap-server/server-query-plugin/query-graphql-plugin/src/main/resources/query-protocol
b/oap-server/server-query-plugin/query-graphql-plugin/src/main/resources/query-protocol
index e93484a89c..6ed9a1bb96 160000
---
a/oap-server/server-query-plugin/query-graphql-plugin/src/main/resources/query-protocol
+++
b/oap-server/server-query-plugin/query-graphql-plugin/src/main/resources/query-protocol
@@ -1 +1 @@
-Subproject commit e93484a89c9d59fda8303f1dc3cac78e64f56bf7
+Subproject commit 6ed9a1bb96c1c753d3211e55995117c9617e4339
diff --git
a/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/stream/BanyanDBLogQueryDAO.java
b/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/stream/BanyanDBLogQueryDAO.java
index 12c9205e54..bd731c9564 100644
---
a/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/stream/BanyanDBLogQueryDAO.java
+++
b/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/stream/BanyanDBLogQueryDAO.java
@@ -118,7 +118,7 @@ public class BanyanDBLogQueryDAO extends
AbstractBanyanDBDAO implements ILogQuer
tsRange = new TimestampRange(TimeBucket.getTimestamp(startTB),
TimeBucket.getTimestamp(endTB));
}
- StreamQueryResponse resp = query(LogRecord.INDEX_NAME, TAGS, tsRange,
query);
+ StreamQueryResponse resp = queryDebuggable(LogRecord.INDEX_NAME, TAGS,
tsRange, query);
Logs logs = new Logs();
diff --git
a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/LogQueryEsDAO.java
b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/LogQueryEsDAO.java
index 5032dd3182..f3359d6eff 100644
---
a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/LogQueryEsDAO.java
+++
b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/LogQueryEsDAO.java
@@ -145,7 +145,7 @@ public class LogQueryEsDAO extends EsDAO implements
ILogQueryDAO {
.size(limit)
.from(from);
- SearchResponse response = getClient().search(new
TimeRangeIndexNameGenerator(
+ SearchResponse response = searchDebuggable(new
TimeRangeIndexNameGenerator(
IndexController.LogicIndicesRegister.getPhysicalTableName(LogRecord.INDEX_NAME),
startSecondTB,
endSecondTB
diff --git a/test/e2e-v2/cases/log/banyandb/docker-compose.yml
b/test/e2e-v2/cases/log/banyandb/docker-compose.yml
new file mode 100644
index 0000000000..d3a0dad769
--- /dev/null
+++ b/test/e2e-v2/cases/log/banyandb/docker-compose.yml
@@ -0,0 +1,53 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+version: '2.1'
+
+services:
+ banyandb:
+ extends:
+ file: ../../../script/docker-compose/base-compose.yml
+ service: banyandb
+ networks:
+ - e2e
+
+ oap:
+ extends:
+ file: ../log-base-compose.yml
+ service: oap
+ environment:
+ SW_STORAGE: banyandb
+ ports:
+ - 12800
+ depends_on:
+ banyandb:
+ condition: service_healthy
+ networks:
+ - e2e
+
+ provider:
+ extends:
+ file: ../../../script/docker-compose/base-compose.yml
+ service: provider
+ ports:
+ - 9090
+ depends_on:
+ oap:
+ condition: service_healthy
+ networks:
+ - e2e
+
+networks:
+ e2e:
diff --git a/test/e2e-v2/cases/log/banyandb/e2e.yaml
b/test/e2e-v2/cases/log/banyandb/e2e.yaml
new file mode 100644
index 0000000000..ca75d051fd
--- /dev/null
+++ b/test/e2e-v2/cases/log/banyandb/e2e.yaml
@@ -0,0 +1,47 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# This file is used to show how to write configuration files and can be used
to test.
+
+setup:
+ env: compose
+ file: docker-compose.yml
+ timeout: 20m
+ init-system-environment: ../../../script/env
+ steps:
+ - name: set PATH
+ command: export PATH=/tmp/skywalking-infra-e2e/bin:$PATH
+ - name: install yq
+ command: bash test/e2e-v2/script/prepare/setup-e2e-shell/install.sh yq
+ - name: install swctl
+ command: bash test/e2e-v2/script/prepare/setup-e2e-shell/install.sh swctl
+
+trigger:
+ action: http
+ interval: 3s
+ times: 10
+ url: http://${provider_host}:${provider_9090}/logs/trigger
+ method: GET
+
+verify:
+ # verify with retry strategy
+ retry:
+ # max retry count
+ count: 20
+ # the interval between two retries, in millisecond.
+ interval: 10s
+ cases:
+ - includes:
+ - ../log-cases.yaml