Skip to content

Commit

Permalink
Reduce Kubernetes metrics calculate in the MQE and Add global widget …
Browse files Browse the repository at this point in the history
…in Kubernetes Dashboard (#12726)
  • Loading branch information
mrproliu authored Oct 26, 2024
1 parent dc762ef commit baa6fcd
Show file tree
Hide file tree
Showing 13 changed files with 438 additions and 280 deletions.
3 changes: 2 additions & 1 deletion docs/en/changes/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
* Add content decorations to Table and Card widgets.
* Support the endpoint list widget query with duration parameter.
* Support ranges for Value Mappings.
* Add service global topN widget on `General-Root` and `Mesh-Root` dashboard.
* Add service global topN widget on `General-Root`, `Mesh-Root`, `K8S-Root` dashboard.
* Fix initialization dashboards.
* Update the Kubernetes metrics for reduce multiple metrics calculate in MQE.

#### Documentation
* Update release document to adopt newly added revision-based process.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public void enterDecorateSource(OALParser.DecorateSourceContext ctx) {
current.setSourceDecorator(decoratorNameTrim);
Map<String, ISourceDecorator<ISource>> map = SourceDecoratorManager.DECORATOR_MAP;
int currentScopeId = current.getFrom().getSourceScopeId();
if (currentScopeId != DefaultScopeDefine.SERVICE) {
if (currentScopeId != DefaultScopeDefine.SERVICE && currentScopeId != DefaultScopeDefine.K8S_SERVICE) {
throw new IllegalArgumentException("OAL metric: " + current.getMetricsName() + ", decorate source only support service scope.");
}
ISourceDecorator<ISource> decorator = map.get(decoratorNameTrim);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public void dispatch(K8SEndpoint source) {
traffic.setTimeBucket(source.getTimeBucket());
traffic.setName(source.getEndpointName());
traffic.setServiceId(source.getServiceId());
traffic.setLastPingTimestamp(source.getTimeBucket());
MetricsStreamProcessor.getInstance().in(traffic);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@
package org.apache.skywalking.oap.server.core.source;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import org.apache.skywalking.oap.server.core.analysis.IDManager;
import org.apache.skywalking.oap.server.core.analysis.ISourceDecorator;
import org.apache.skywalking.oap.server.core.analysis.Layer;
import org.apache.skywalking.oap.server.core.analysis.SourceDecoratorManager;

import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.K8S_SERVICE;
import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.SERVICE_CATALOG_NAME;
Expand All @@ -38,6 +42,27 @@ public class K8SService extends K8SMetrics {

private DetectPoint detectPoint;

@Getter
@Setter
@ScopeDefaultColumn.DefinedByField(columnName = "attr0", isAttribute = true)
private String attr0;
@Getter
@Setter
@ScopeDefaultColumn.DefinedByField(columnName = "attr1", isAttribute = true)
private String attr1;
@Getter
@Setter
@ScopeDefaultColumn.DefinedByField(columnName = "attr2", isAttribute = true)
private String attr2;
@Getter
@Setter
@ScopeDefaultColumn.DefinedByField(columnName = "attr3", isAttribute = true)
private String attr3;
@Getter
@Setter
@ScopeDefaultColumn.DefinedByField(columnName = "attr4", isAttribute = true)
private String attr4;

@Override
public int scope() {
return K8S_SERVICE;
Expand All @@ -47,4 +72,13 @@ public int scope() {
public void prepare() {
entityId = IDManager.ServiceID.buildId(name, layer.isNormal());
}

/**
* Get the decorator through given name and invoke.
* @param decorator The decorator class simpleName.
*/
public void decorate(String decorator) {
ISourceDecorator<ISource> sourceDecorator = SourceDecoratorManager.DECORATOR_MAP.get(decorator);
sourceDecorator.decorate(this);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* 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.source;

import org.apache.skywalking.oap.server.core.analysis.ISourceDecorator;

public class K8SServiceDecorator implements ISourceDecorator<K8SService> {
@Override
public int getSourceScope() {
return DefaultScopeDefine.K8S_SERVICE;
}

/**
* Set the Layer name to attr0
* @param source The source instance to be decorated
*/
@Override
public void decorate(final K8SService source) {
source.setAttr0(source.getLayer().name());
}
}
Loading

0 comments on commit baa6fcd

Please sign in to comment.