Skip to content

Commit

Permalink
Support Get Effective TTL Configurations API. (#12847)
Browse files Browse the repository at this point in the history
* [Breaking Change] Rename `debugging-query` module to `status-query` module. Relative exposed APIs are **UNCHANGED**. 
* Support `Get Effective TTL Configurations` API.
  • Loading branch information
wu-sheng authored Dec 12, 2024
1 parent 1c9c685 commit 841a92b
Show file tree
Hide file tree
Showing 45 changed files with 527 additions and 58 deletions.
3 changes: 3 additions & 0 deletions docs/en/changes/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* This change would not impact the existing deployment and its feature for our official release users.
* **Warning** If there are custom query plugins for our Elasticsearch indices, this change could break them as
sort queries and aggregation queries which used the unexpected fields are being blocked.
* [Breaking Change] Rename `debugging-query` module to `status-query` module. Relative exposed APIs are **UNCHANGED**.

#### OAP Server

Expand Down Expand Up @@ -34,6 +35,7 @@
* BanyanDB: Support update the Schema when OAP starting.
* BanyanDB: Speed up OAP booting while initializing BanyanDB.
* BanyanDB: Support `@EnableSort` on the column to enable sorting for `IndexRule` and set the default to false.
* Support `Get Effective TTL Configurations` API.

#### UI

Expand Down Expand Up @@ -61,5 +63,6 @@
* Improve BanyanDB documentation.
* Improve component-libraries documentation.
* Improve configuration-vocabulary documentation.
* Add `Get Effective TTL Configurations` API documentation.

All issues and pull requests are [here](https://github.com/apache/skywalking/milestone/224?closed=1)
13 changes: 7 additions & 6 deletions docs/en/debugging/config_dump.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# Scratch The OAP Config Dump
# Dump Effective Initial Configurations

SkyWalking OAP behaviors could be controlled through hundreds of configurations. It is hard to know what is the final
configuration as all the configurations could be overrided by system environments.
configuration as all the configurations could be override by system environments.

The core config file [application.yml](../../../oap-server/server-starter/src/main/resources/application.yml) lists all
the configurations
The core config file [application.yml](../../../oap-server/server-starter/src/main/resources/application.yml) lists all the configurations
and their default values. However, it is still hard to know the runtime value.

Scratch is a tool to dump the final configuration. It is provided within OAP rest server, which could be accessed
through HTTP GET `http://{core restHost}:{core restPort}/debugging/config/dump`.
Dump Effective Initial Configurations API is designed to help users to understand the effective configurations, no matter
they are initialized in the `application.yml`, or override through system environments.
- URL, `http://{core restHost}:{core restPort}/debugging/config/dump`
- HTTP GET method.

```shell
> curl http://127.0.0.1:12800/debugging/config/dump
Expand Down
2 changes: 1 addition & 1 deletion docs/en/setup/backend/configuration-vocabulary.md
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ The Configuration Vocabulary lists all available configurations provided by `app
| - | - | kafkaTopicLog | Kafka topic name for log. | SW_EXPORTER_KAFKA_TOPIC_LOG | skywalking-export-log |
| - | - | exportErrorStatusTraceOnly | Export error status trace segments through the Kafka channel. | SW_EXPORTER_KAFKA_TRACE_FILTER_ERROR | false |
| health-checker | default | checkIntervalSeconds | The period of checking OAP internal health status (in seconds). | SW_HEALTH_CHECKER_INTERVAL_SECONDS | 5 |
| debugging-query | default | | | | |
| status-query | default | | | | |
| - | - | keywords4MaskingSecretsOfConfig | Include the list of keywords to filter configurations including secrets. Separate keywords by a comma. | SW_DEBUGGING_QUERY_KEYWORDS_FOR_MASKING_SECRETS | user,password,token,accessKey,secretKey,authentication |
| configuration-discovery | default | disableMessageDigest | If true, agent receives the latest configuration every time, even without making any changes. By default, OAP uses the SHA512 message digest mechanism to detect changes in configuration. | SW_DISABLE_MESSAGE_DIGEST | false |
| receiver-event | default | gRPC services that handle events data. | - | - | |
Expand Down
11 changes: 8 additions & 3 deletions docs/en/setup/backend/ttl.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# TTL
# Data Lifecycle. Time To Live (TTL)
Time To Live (TTL) is a mechanism to automatically delete data that is older than the specified time.

In SkyWalking, there are two types of observability data:
1. Records include traces, logs, topN sampled statements and alarm. `recordDataTTL` applies to **record** data.
1. Metrics include all metrics for service, instance, endpoint, and topology map. Metadata(lists of services, instances, or endpoints) also belongs to metrics. `metricsDataTTL` applies to **Metrics** data.
Expand All @@ -12,6 +14,9 @@ These are the settings for the different types:
## BanyanDB TTL
BanyanDB has a TTL mechanism to automatically delete data that is older than the specified time. When you use BanyanDB as the storage backend, `recordDataTTL` and `metricsDataTTL` are not used. Instead, you should configure the TTL settings in `storage.banyandb`.
BanyanDB has a TTL mechanism to automatically delete data that is older than the specified time. When you use BanyanDB
as the storage backend, `recordDataTTL` and `metricsDataTTL` are not used. Instead, you should configure the TTL
settings in `storage.banyandb`.

Please refer to the [Storage BanyanDB](storages/banyandb.md) document for more information.
Please refer to the [Storage BanyanDB](storages/banyandb.md) and [BanyanDB's Progressive TTL](../../banyandb/ttl.md)
documents for more information.
48 changes: 48 additions & 0 deletions docs/en/status/query_ttl_setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Get Effective TTL Configurations

Time To Live (TTL) mechanism has different behaviors according to different storage implementations. By default, the
core module provides two TTL configurations: [`recordDataTTL` and `metricsDataTTL`](../setup/backend/ttl.md).
But some storage implementations could override these settings and provide its own TTL configurations, for example,
BanyanDB provides its native TTL mechanism to support [progressive TTL](../banyandb/ttl.md) feature.

This API is used to get the unified and effective TTL configurations.
- URL, `http://{core restHost}:{core restPort}/status/config/ttl`
- HTTP GET method.

```shell
> curl -X GET "http://127.0.0.1:12800/status/config/ttl"
# Metrics TTL includes the definition of the TTL of the metrics-ish data in the storage,
# e.g.
# 1. The metadata of the service, instance, endpoint, topology map, etc.
# 2. Generated metrics data from OAL and MAL engines.
#
# TTLs for each granularity metrics are listed separately.
metrics.minute=7
metrics.hour=7
metrics.day=7

# Records TTL includes the definition of the TTL of the records data in the storage,
# Records include traces, logs, sampled slow SQL statements, HTTP requests(by Rover), alarms, etc.
# Super dataset of records are traces and logs, which volume should be much larger.
records.default=3
records.superDataset=3
```

This API also provides the response in JSON format, which is more friendly for programmatic usage.

```shell
> curl -X GET "http://127.0.0.1:12800/status/config/ttl" \
-H "Accept: application/json"

{
"metrics": {
"minute": 7,
"hour": 7,
"day": 7
},
"records": {
"default": 3,
"superDataset": 3
}
}
```
6 changes: 4 additions & 2 deletions docs/menu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -352,12 +352,14 @@ catalog:
path: "/en/concepts-and-designs/metrics-attributes"
- name: "Security Notice"
path: "/en/security/readme"
- name: "Debugging"
- name: "Status APIs"
catalog:
- name: "Scratch The OAP Config Dump"
- name: "Dump Effective Initial Configurations"
path: "/en/debugging/config_dump"
- name: "Tracing Query Execution"
path: "/en/debugging/query-tracing"
- name: "Get Effective TTL Configurations"
path: "/en/status/query_ttl_setup"
- name: "Academy"
catalog:
- name: "Scaling SkyWalking server automatically in kubernetes"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import org.apache.skywalking.oap.server.core.query.MetricsMetadataQueryService;
import org.apache.skywalking.oap.server.core.query.MetricsQueryService;
import org.apache.skywalking.oap.server.core.query.RecordQueryService;
import org.apache.skywalking.oap.server.core.query.TTLStatusQuery;
import org.apache.skywalking.oap.server.core.query.TagAutoCompleteQueryService;
import org.apache.skywalking.oap.server.core.query.TopNRecordsQueryService;
import org.apache.skywalking.oap.server.core.query.TopologyQueryService;
Expand Down Expand Up @@ -96,7 +97,7 @@ public Class[] services() {

addServerInterface(classes);
addReceiverInterface(classes);
addInsideService(classes);
addInternalServices(classes);
addCacheService(classes);
addQueryService(classes);
addProfileService(classes);
Expand Down Expand Up @@ -153,14 +154,15 @@ private void addQueryService(List<Class> classes) {
classes.add(TagAutoCompleteQueryService.class);
classes.add(RecordQueryService.class);
classes.add(HierarchyQueryService.class);
classes.add(TTLStatusQuery.class);
}

private void addServerInterface(List<Class> classes) {
classes.add(GRPCHandlerRegister.class);
classes.add(HTTPHandlerRegister.class);
}

private void addInsideService(List<Class> classes) {
private void addInternalServices(List<Class> classes) {
classes.add(ModelCreator.class);
classes.add(IModelManager.class);
classes.add(ModelManipulator.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
import org.apache.skywalking.oap.server.core.query.MetricsMetadataQueryService;
import org.apache.skywalking.oap.server.core.query.MetricsQueryService;
import org.apache.skywalking.oap.server.core.query.RecordQueryService;
import org.apache.skywalking.oap.server.core.query.TTLStatusQuery;
import org.apache.skywalking.oap.server.core.query.TagAutoCompleteQueryService;
import org.apache.skywalking.oap.server.core.query.TopNRecordsQueryService;
import org.apache.skywalking.oap.server.core.query.TopologyQueryService;
Expand Down Expand Up @@ -304,6 +305,13 @@ public void prepare() throws ServiceNotProvidedException, ModuleStartException {
TagAutoCompleteQueryService.class, new TagAutoCompleteQueryService(getManager(), moduleConfig));
this.registerServiceImplementation(RecordQueryService.class, new RecordQueryService(getManager()));
this.registerServiceImplementation(HierarchyQueryService.class, new HierarchyQueryService(getManager(), moduleConfig));
this.registerServiceImplementation(
TTLStatusQuery.class, new TTLStatusQuery(
getManager(),
moduleConfig.getMetricsDataTTL(),
moduleConfig.getRecordDataTTL()
)
);

// add profile service implementations
this.registerServiceImplementation(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* 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.
*
*/

package org.apache.skywalking.oap.server.core.query;

import lombok.RequiredArgsConstructor;
import org.apache.skywalking.oap.server.core.storage.StorageModule;
import org.apache.skywalking.oap.server.core.storage.ttl.MetricsTTL;
import org.apache.skywalking.oap.server.core.storage.ttl.RecordsTTL;
import org.apache.skywalking.oap.server.core.storage.ttl.StorageTTLStatusQuery;
import org.apache.skywalking.oap.server.core.storage.ttl.TTLDefinition;
import org.apache.skywalking.oap.server.library.module.ModuleManager;
import org.apache.skywalking.oap.server.library.module.Service;

@RequiredArgsConstructor
public class TTLStatusQuery implements Service {
private final ModuleManager moduleManager;
private final int coreMetricsDataTTL;
private final int coreRecordDataTTL;

private StorageTTLStatusQuery storageTTLStatusQuery;

private StorageTTLStatusQuery getStorageTTLStatusQuery() {
if (storageTTLStatusQuery == null) {
storageTTLStatusQuery = moduleManager.find(StorageModule.NAME)
.provider()
.getService(StorageTTLStatusQuery.class);
}
return storageTTLStatusQuery;
}

/**
* @return effective TTL configuration values.
*/
public TTLDefinition getTTL() {
TTLDefinition ttlDefinition = getStorageTTLStatusQuery().getTTL();
if (ttlDefinition == null) {
ttlDefinition = new TTLDefinition(
new MetricsTTL(coreMetricsDataTTL, coreMetricsDataTTL, coreMetricsDataTTL),
new RecordsTTL(coreRecordDataTTL, coreRecordDataTTL)
);
}
return ttlDefinition;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.apache.skywalking.oap.server.core.storage.query.ITopologyQueryDAO;
import org.apache.skywalking.oap.server.core.storage.query.ITraceQueryDAO;
import org.apache.skywalking.oap.server.core.storage.query.IZipkinQueryDAO;
import org.apache.skywalking.oap.server.core.storage.ttl.StorageTTLStatusQuery;
import org.apache.skywalking.oap.server.library.module.ModuleDefine;

/**
Expand Down Expand Up @@ -95,6 +96,7 @@ public Class[] services() {
IAsyncProfilerTaskQueryDAO.class,
IAsyncProfilerTaskLogQueryDAO.class,
IJFRDataQueryDAO.class,
StorageTTLStatusQuery.class
};
}
}
Loading

0 comments on commit 841a92b

Please sign in to comment.