Skip to content

Commit 859a462

Browse files
authored
GraphQL API: metadata, topology, log and trace support query by name. (#13388)
1 parent f930830 commit 859a462

File tree

14 files changed

+522
-21
lines changed

14 files changed

+522
-21
lines changed

docs/en/api/query-protocol.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,15 @@ extend type Query {
2828

2929
# Read service instance list.
3030
listInstances(duration: Duration!, serviceId: ID!): [ServiceInstance!]!
31+
listInstancesByName(duration: Duration!, service: ServiceCondition!): [ServiceInstance!]!
3132
# Search and find service instance according to given ID. Return null if not existing.
3233
getInstance(instanceId: String!): ServiceInstance
3334

3435
# Search and find matched endpoints according to given service and keyword(optional)
3536
# If no keyword, randomly choose endpoint based on `limit` value.
36-
findEndpoint(keyword: String, serviceId: ID!, limit: Int!): [Endpoint!]!
37+
# If duration is nil mean get all endpoints, otherwise, get the endpoint list in the given duration.
38+
findEndpoint(keyword: String, serviceId: ID!, limit: Int!, duration: Duration): [Endpoint!]!
39+
findEndpointByName(keyword: String, service: ServiceCondition!, limit: Int!, duration: Duration): [Endpoint!]!
3740
getEndpointInfo(endpointId: ID!): EndpointInfo
3841

3942
# Read process list.
@@ -66,17 +69,22 @@ extend type Query {
6669
getGlobalTopology(duration: Duration!, layer: String, debug: Boolean): Topology
6770
# Query the topology, based on the given service
6871
getServiceTopology(serviceId: ID!, duration: Duration!, debug: Boolean): Topology
72+
getServiceTopologyByName(service: ServiceCondition!, duration: Duration!, debug: Boolean): Topology
6973
# Query the topology, based on the given services.
7074
# `#getServiceTopology` could be replaced by this.
7175
getServicesTopology(serviceIds: [ID!]!, duration: Duration!, debug: Boolean): Topology
76+
getServicesTopologyByNames(services: [ServiceCondition!]!, duration: Duration!, debug: Boolean): Topology
7277
# Query the instance topology, based on the given clientServiceId and serverServiceId
7378
getServiceInstanceTopology(clientServiceId: ID!, serverServiceId: ID!, duration: Duration!, debug: Boolean): ServiceInstanceTopology
79+
getServiceInstanceTopologyByName(clientService: ServiceCondition!, serverService: ServiceCondition!, duration: Duration!, debug: Boolean): ServiceInstanceTopology
7480
# Query the topology, based on the given endpoint
7581
getEndpointTopology(endpointId: ID!, duration: Duration!): Topology
7682
# v2 of getEndpointTopology
7783
getEndpointDependencies(endpointId: ID!, duration: Duration!, debug: Boolean): EndpointTopology
84+
getEndpointDependenciesByName(endpoint: EndpointCondition!, duration: Duration!, debug: Boolean): EndpointTopology
7885
# Query the topology, based on the given instance
7986
getProcessTopology(serviceInstanceId: ID!, duration: Duration!, debug: Boolean): ProcessTopology
87+
getProcessTopologyByName(instance: InstanceCondition!, duration: Duration!, debug: Boolean): ProcessTopology
8088
}
8189
```
8290

@@ -138,6 +146,7 @@ extend type Query {
138146
# Return true if the current storage implementation supports fuzzy query for logs.
139147
supportQueryLogsByKeywords: Boolean!
140148
queryLogs(condition: LogQueryCondition, debug: Boolean): Logs
149+
queryLogsByName(condition: LogQueryConditionByName, debug: Boolean): Logs
141150
# Test the logs and get the results of the LAL output.
142151
test(requests: LogTestRequest!): LogTestResponse!
143152
# Read the list of searchable keys
@@ -158,6 +167,7 @@ full log text fuzzy queries, while others do not due to considerations related t
158167
extend type Query {
159168
# Search segment list with given conditions
160169
queryBasicTraces(condition: TraceQueryCondition, debug: Boolean): TraceBrief
170+
queryBasicTracesByName(condition: TraceQueryConditionByName, debug: Boolean): TraceBrief
161171
# Read the specific trace ID with given trace ID
162172
queryTrace(traceId: ID!, debug: Boolean): Trace
163173
# Only for BanyanDB, can be used to query the trace in the cold stage.

docs/en/changes/changes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
* Fix analysis tracing profiling span failure in ES storage.
4646
* Add UI dashboard for Ruby runtime metrics.
4747
* Tracing Query Execution HTTP APIs: make the argument `service layer` optional.
48+
* GraphQL API: metadata, topology, log and trace support query by name.
4849

4950
#### UI
5051

docs/en/debugging/query-tracing.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ SkyWalking OAP provides the metrics/trace/log/topology query tracing to help use
3131
The query tracing service is provided within the OAP rest server,
3232
which could be accessed through HTTP GET `http://{core restHost}:{core restPort}/debugging/query/...`.
3333

34-
**Note:** The `layer` of the service is optional, but if the service is virtual then required, such the `layer` is `VIRTUAL_DATABASE/VIRTUAL_MQ/VIRTUAL_GATEWAY`.
34+
**Note:** The `layer` of the service is optional, but if the service is virtual then required, such the `layer` is `UNDEFINED/VIRTUAL_DATABASE/VIRTUAL_MQ/VIRTUAL_GATEWAY`.
3535

3636
### Tracing MQE Execution
3737
- URL: HTTP GET `http://{core restHost}:{core restPort}/debugging/query/mqe?{parameters}`.
@@ -694,6 +694,7 @@ the debuggingTrace will include the BanyanDB internal execution trace info, such
694694
extend type Query {
695695
# Search segment list with given conditions
696696
queryBasicTraces(condition: TraceQueryCondition, debug: Boolean): TraceBrief
697+
queryBasicTracesByName(condition: TraceQueryConditionByName, debug: Boolean): TraceBrief
697698
# Read the specific trace ID with given trace ID
698699
queryTrace(traceId: ID!, debug: Boolean): Trace
699700
...
@@ -732,16 +733,21 @@ extend type Query {
732733
getGlobalTopology(duration: Duration!, layer: String, debug: Boolean): Topology
733734
# Query the topology, based on the given service
734735
getServiceTopology(serviceId: ID!, duration: Duration!, debug: Boolean): Topology
736+
getServiceTopologyByName(service: ServiceCondition!, duration: Duration!, debug: Boolean): Topology
735737
# Query the topology, based on the given services.
736738
# `#getServiceTopology` could be replaced by this.
737739
getServicesTopology(serviceIds: [ID!]!, duration: Duration!, debug: Boolean): Topology
740+
getServicesTopologyByNames(services: [ServiceCondition!]!, duration: Duration!, debug: Boolean): Topology
738741
# Query the instance topology, based on the given clientServiceId and serverServiceId
739742
getServiceInstanceTopology(clientServiceId: ID!, serverServiceId: ID!, duration: Duration!, debug: Boolean): ServiceInstanceTopology
743+
getServiceInstanceTopologyByName(clientService: ServiceCondition!, serverService: ServiceCondition!, duration: Duration!, debug: Boolean): ServiceInstanceTopology
740744
...
741745
# v2 of getEndpointTopology
742746
getEndpointDependencies(endpointId: ID!, duration: Duration!, debug: Boolean): EndpointTopology
747+
getEndpointDependenciesByName(endpoint: EndpointCondition!, duration: Duration!, debug: Boolean): EndpointTopology
743748
# Query the topology, based on the given instance
744749
getProcessTopology(serviceInstanceId: ID!, duration: Duration!, debug: Boolean): ProcessTopology
750+
getProcessTopologyByName(instance: InstanceCondition!, duration: Duration!, debug: Boolean): ProcessTopology
745751
}
746752
```
747753
@@ -786,6 +792,7 @@ just enable the debug parameter to true.
786792
extend type Query {
787793
...
788794
queryLogs(condition: LogQueryCondition, debug: Boolean): Logs
795+
queryLogsByName(condition: LogQueryConditionByName, debug: Boolean): Logs
789796
...
790797
}
791798
```
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
package org.apache.skywalking.oap.server.core.query.input;
20+
21+
import javax.annotation.Nullable;
22+
import lombok.Getter;
23+
import lombok.Setter;
24+
import lombok.ToString;
25+
import org.apache.skywalking.oap.server.core.analysis.IDManager;
26+
import org.apache.skywalking.oap.server.core.analysis.Layer;
27+
28+
@Setter
29+
@Getter
30+
@ToString
31+
public class EndpointCondition {
32+
private String serviceName;
33+
private String endpointName;
34+
@Nullable
35+
private String layer;
36+
37+
/**
38+
* Get the endpoint ID based on the service name, endpoint name and {@link Layer} name.
39+
* The layer can be null, in which case it defaults to a normal layer.
40+
* Otherwise, it uses the provided layer to determine if the service is normal or not.
41+
* The un-normal layer includes VIRTUAL_DATABASE/VIRTUAL_MQ/VIRTUAL_GATEWAY, etc.
42+
*
43+
* @return endpoint ID
44+
*/
45+
public String getEndpointId() {
46+
// default to true if service layer is not provided
47+
return IDManager.EndpointID.buildId(
48+
IDManager.ServiceID.buildId(
49+
serviceName,
50+
layer == null || Layer.nameOf(layer).isNormal()
51+
),
52+
endpointName
53+
);
54+
}
55+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
package org.apache.skywalking.oap.server.core.query.input;
20+
21+
import javax.annotation.Nullable;
22+
import lombok.Getter;
23+
import lombok.Setter;
24+
import lombok.ToString;
25+
import org.apache.skywalking.oap.server.core.analysis.IDManager;
26+
import org.apache.skywalking.oap.server.core.analysis.Layer;
27+
28+
@Setter
29+
@Getter
30+
@ToString
31+
public class InstanceCondition {
32+
private String serviceName;
33+
private String instanceName;
34+
@Nullable
35+
private String layer;
36+
37+
/**
38+
* Get the instance ID based on the service name, instance name and {@link Layer} name.
39+
* The layer can be null, in which case it defaults to a normal layer.
40+
* Otherwise, it uses the provided layer to determine if the service is normal or not.
41+
* The un-normal layer includes VIRTUAL_DATABASE/VIRTUAL_MQ/VIRTUAL_GATEWAY, etc.
42+
* @return instance ID
43+
*/
44+
public String getInstanceId() {
45+
// default to true if service layer is not provided
46+
return IDManager.ServiceInstanceID.buildId(
47+
IDManager.ServiceID.buildId(
48+
serviceName,
49+
layer == null || Layer.nameOf(layer).isNormal()
50+
),
51+
instanceName
52+
);
53+
}
54+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
package org.apache.skywalking.oap.server.core.query.input;
20+
21+
import java.util.List;
22+
import lombok.Getter;
23+
import lombok.Setter;
24+
import lombok.ToString;
25+
import org.apache.skywalking.oap.server.core.analysis.manual.searchtag.Tag;
26+
import org.apache.skywalking.oap.server.core.query.enumeration.Order;
27+
import org.apache.skywalking.oap.server.core.query.type.Pagination;
28+
29+
@Getter
30+
@Setter
31+
@ToString
32+
public class LogQueryConditionByName {
33+
private ServiceCondition service;
34+
private InstanceCondition instance;
35+
private EndpointCondition endpoint;
36+
private TraceScopeCondition relatedTrace;
37+
private Duration queryDuration;
38+
private Pagination paging;
39+
private List<Tag> tags;
40+
private List<String> keywordsOfContent;
41+
private List<String> excludingKeywordsOfContent;
42+
private Order queryOrder;
43+
44+
public String getServiceId() {
45+
if (service != null) {
46+
return service.getServiceId();
47+
} else {
48+
return null;
49+
}
50+
}
51+
52+
public String getServiceInstanceId() {
53+
if (instance != null) {
54+
return instance.getInstanceId();
55+
} else {
56+
return null;
57+
}
58+
}
59+
60+
public String getEndpointId() {
61+
if (endpoint != null) {
62+
return endpoint.getEndpointId();
63+
} else {
64+
return null;
65+
}
66+
}
67+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
package org.apache.skywalking.oap.server.core.query.input;
20+
21+
import javax.annotation.Nullable;
22+
import lombok.Getter;
23+
import lombok.Setter;
24+
import lombok.ToString;
25+
import org.apache.skywalking.oap.server.core.analysis.IDManager;
26+
import org.apache.skywalking.oap.server.core.analysis.Layer;
27+
28+
@Setter
29+
@Getter
30+
@ToString
31+
public class ServiceCondition {
32+
private String serviceName;
33+
@Nullable
34+
private String layer;
35+
36+
/**
37+
* Get the service ID based on the service name and {@link Layer} name.
38+
* The layer can be null, in which case it defaults to a normal layer.
39+
* Otherwise, it uses the provided layer to determine if the service is normal or not.
40+
* The un-normal layer includes VIRTUAL_DATABASE/VIRTUAL_MQ/VIRTUAL_GATEWAY, etc.
41+
* @return service ID
42+
*/
43+
public String getServiceId() {
44+
// default to true if service layer is not provided
45+
return IDManager.ServiceID.buildId(serviceName, layer == null || Layer.nameOf(layer).isNormal());
46+
}
47+
}

0 commit comments

Comments
 (0)