Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/configuration/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ There are four JVM parameters that we set on all of our services:
* The temp directory should not be volatile tmpfs.
* This directory should also have good read and write speed.
* Avoid NFS mount.
* The `org.apache.druid.java.util.metrics.SysMonitor` requires execute privileges on files in `java.io.tmpdir`. If you are using the system monitor, do not set `java.io.tmpdir` to `noexec`.
* `-Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager` This allows log4j2 to handle logs for non-log4j2 components (like jetty) which use standard java logging.

### Extensions
Expand Down
28 changes: 1 addition & 27 deletions docs/operations/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ Most metric values reset each emission period, as specified in `druid.monitoring
### Real-time

:::info
Monitors on peons that previously emitted the `id` dimension from `JettyMonitor`, `OshiSysMonitor`, `JvmMonitor`, `JvmCpuMonitor`, `JvmThreadsMonitor` and `SysMonitor`
Monitors on peons that previously emitted the `id` dimension from `JettyMonitor`, `OshiSysMonitor`, `JvmMonitor`, `JvmCpuMonitor` and `JvmThreadsMonitor`
to represent the task ID are deprecated and will be removed in a future release. Use the `taskId` dimension instead.
:::

Expand Down Expand Up @@ -574,32 +574,6 @@ These metrics are available only when `druid.zk.service.enabled = true`.
|`zk/connected`|Indicator of connection status. `1` for connected, `0` for disconnected. Emitted once per monitor period.|None|1|
|`zk/reconnect/time`|Amount of time, in milliseconds, that a server was disconnected from ZooKeeper before reconnecting. Emitted on reconnection. Not emitted if connection to ZooKeeper is permanently lost, because in this case, there is no reconnection.|None|Not present|

## Sys [Deprecated]

> SysMonitor is now deprecated and will be removed in future releases.
> Instead, use the new OSHI monitor called [OshiSysMonitor](#oshisysmonitor). The new monitor has a wider support for different machine architectures including ARM instances.

These metrics are only available if the `SysMonitor` module is included.

|Metric|Description|Dimensions|Normal value|
|------|-----------|----------|------------|
|`sys/swap/free`|Free swap||Varies|
|`sys/swap/max`|Max swap||Varies|
|`sys/swap/pageIn`|Paged in swap||Varies|
|`sys/swap/pageOut`|Paged out swap||Varies|
|`sys/disk/write/count`|Writes to disk|`fsDevName`, `fsDirName`, `fsTypeName`, `fsSysTypeName`, `fsOptions`|Varies|
|`sys/disk/read/count`|Reads from disk|`fsDevName`, `fsDirName`, `fsTypeName`, `fsSysTypeName`, `fsOptions`|Varies|
|`sys/disk/write/size`|Bytes written to disk. One indicator of the amount of paging occurring for segments.|`fsDevName`,`fsDirName`,`fsTypeName`, `fsSysTypeName`, `fsOptions`|Varies|
|`sys/disk/read/size`|Bytes read from disk. One indicator of the amount of paging occurring for segments.|`fsDevName`,`fsDirName`, `fsTypeName`, `fsSysTypeName`, `fsOptions`|Varies|
|`sys/net/write/size`|Bytes written to the network|`netName`, `netAddress`, `netHwaddr`|Varies|
|`sys/net/read/size`|Bytes read from the network|`netName`, `netAddress`, `netHwaddr`|Varies|
|`sys/fs/used`|Filesystem bytes used|`fsDevName`, `fsDirName`, `fsTypeName`, `fsSysTypeName`, `fsOptions`|< max|
|`sys/fs/max`|Filesystem bytes max|`fsDevName`, `fsDirName`, `fsTypeName`, `fsSysTypeName`, `fsOptions`|Varies|
|`sys/mem/used`|Memory used||< max|
|`sys/mem/max`|Memory max||Varies|
|`sys/storage/used`|Disk space used|`fsDirName`|Varies|
|`sys/cpu`|CPU used|`cpuName`, `cpuTime`|Varies|

## OshiSysMonitor

These metrics are only available if the `OshiSysMonitor` module is included.
Expand Down
129 changes: 0 additions & 129 deletions licenses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2602,135 +2602,6 @@ libraries:

---

name: SIGAR
license_category: binary
module: java-core
license_name: Apache License version 2.0
version: 1.6.5.132-6
libraries:
- org.hyperic: sigar
notices:
- sigar: |
Copyright (c) 2004-2011 VMware, Inc.

Licensed 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.

ADDITIONAL LICENSE INFORMATION:

Hyperic SIGAR includes some third-party open source components
in its distribution. The list below identifies the community or
organization and links to their appropriate license terms.

The Hyperic team would like to thank all the communities
of the projects listed below for their contributions.

----------------------------------------------------------
Components under the Apache License 2.0:
----------------------------------------------------------

The following components are included without modification:

- log4j -
Information: http://logging.apache.org/
License: http://www.apache.org/licenses/LICENSE-2.0

The following components are included with modification:

- cpptasks -
Information: http://ant-contrib.sourceforge.net/
License: http://www.apache.org/licenses/LICENSE-2.0

- (portions of) APR -
Information: http://apr.apache.org/
License: http://www.apache.org/licenses/LICENSE-2.0

----------------------------------------------------------
Components under BSD/MIT Style Licenses:
----------------------------------------------------------

The following components are included with modification:

- solaris get_mib2 -
Information: ftp://vic.cc.purdue.edu/pub/tools/unix/solaris/get_mib2/
License: within src/os/solaris/get_mib2.[ch]

Copyright 1995 Purdue Research Foundation, West Lafayette, Indiana
47907. All rights reserved.

Written by Victor A. Abell <abe@cc.purdue.edu>

This software is not subject to any license of the American Telephone
and Telegraph Company or the Regents of the University of California.

Permission is granted to anyone to use this software for any purpose on
any computer system, and to alter it and redistribute it freely, subject
to the following restrictions:

1. Neither Victor A Abell nor Purdue University are responsible for
any consequences of the use of this software.

2. The origin of this software must not be misrepresented, either by
explicit claim or by omission. Credit to Victor A. Abell and Purdue
University must appear in documentation and sources.

3. Altered versions must be plainly marked as such, and must not be
misrepresented as being the original software.

4. This notice may not be removed or altered.

- getline by Chris Thewalt -
Information: http://tinyurl.com/r438r
License: within src/sigar_getline.c

Copyright (C) 1991, 1992 by Chris Thewalt (thewalt@ce.berkeley.edu)

Permission to use, copy, modify, and distribute this software
for any purpose and without fee is hereby granted, provided
that the above copyright notices appear in all copies and that both the
copyright notice and this permission notice appear in supporting
documentation. This software is provided "as is" without express or
implied warranty.

- PrintfFormat.java -
Information: http://java.sun.com/developer/technicalArticles/Programming/sprintf/PrintfFormat.java
License: within bindings/java/src/org/hyperic/sigar/util/PrintfFormat.java

(c) 2000 Sun Microsystems, Inc.
ALL RIGHTS RESERVED

License Grant-

Permission to use, copy, modify, and distribute this Software and its
documentation for NON-COMMERCIAL or COMMERCIAL purposes and without fee is
hereby granted.

This Software is provided "AS IS". All express warranties, including any
implied warranty of merchantability, satisfactory quality, fitness for a
particular purpose, or non-infringement, are disclaimed, except to the extent
that such disclaimers are held to be legally invalid.

You acknowledge that Software is not designed, licensed or intended for use in
the design, construction, operation or maintenance of any nuclear facility
("High Risk Activities"). Sun disclaims any express or implied warranty of
fitness for such uses.

Please refer to the file http://www.sun.com/policies/trademarks/ for further
important trademark information and to
http://java.sun.com/nav/business/index.html for further important licensing
information for the Java Technology.

---

name: OSHI
license_category: binary
module: java-core
Expand Down
9 changes: 0 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -291,15 +291,6 @@
</snapshots>
</repository>

<!-- Only used by core, but moved to root for parallel build dependency resolution -->
<repository>
<id>sigar</id>
<url>https://repository.mulesoft.org/nexus/content/repositories/public</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>

<repository>
<id>cflt-public</id>
<url>https://packages.confluent.io/maven/</url>
Expand Down
38 changes: 0 additions & 38 deletions processing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<sigar.base.version>1.6.5</sigar.base.version>
<sigar.version>1.6.5.132-6</sigar.version>
<oshi.version>7.6.0</oshi.version>
<mariadb.legacy.version>2.7.3</mariadb.legacy.version>
</properties>
Expand Down Expand Up @@ -321,21 +319,6 @@
<artifactId>async-http-client</artifactId>
</dependency>

<!-- Extra dependencies for server-metrics -->
<dependency>
<groupId>org.hyperic</groupId>
<artifactId>sigar</artifactId>
<version>${sigar.version}</version>
</dependency>
<dependency>
<groupId>org.hyperic</groupId>
<artifactId>sigar-dist</artifactId>
<version>${sigar.version}</version>
<type>zip</type>
<!-- "Provided" because this dependency is used only during the build itself: some files from this
dependency are copied as resources. See maven-dependency-plugin configuration and <resources> below. -->
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.oshi</groupId>
<artifactId>oshi-core</artifactId>
Expand Down Expand Up @@ -495,22 +478,6 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-sigar-lib-to-resources</id>
<phase>generate-resources</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<includeGroupIds>org.hyperic</includeGroupIds>
<includeArtifactIds>sigar-dist</includeArtifactIds>
<includes>**/sigar-bin/lib/*</includes>
<excludes>**/sigar-bin/lib/*jar</excludes>
<outputDirectory>
${project.build.directory}
</outputDirectory>
</configuration>
</execution>
<execution>
<id>copy-mariadb-legacy-test-driver</id>
<phase>generate-test-resources</phase>
Expand Down Expand Up @@ -566,11 +533,6 @@
<include>loggingEmitterAllowedMetrics.json</include>
</includes>
</resource>
<resource>
<directory>
${project.build.directory}/hyperic-sigar-${sigar.base.version}/sigar-bin/lib
</directory>
</resource>
</resources>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,60 +19,78 @@

package org.apache.druid.java.util.metrics;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableMap;
import org.apache.druid.java.util.common.logger.Logger;
import org.apache.druid.java.util.emitter.service.ServiceEmitter;
import org.apache.druid.java.util.emitter.service.ServiceMetricEvent;
import org.hyperic.sigar.ProcCpu;
import org.hyperic.sigar.Sigar;
import org.hyperic.sigar.SigarException;
import oshi.SystemInfo;
import oshi.software.os.OSProcess;
import oshi.software.os.OperatingSystem;

import java.util.Map;

public class JvmCpuMonitor extends FeedDefiningMonitor
{
private static final Logger log = new Logger(JvmCpuMonitor.class);

private final Sigar sigar = SigarUtil.getSigar();
private final long currentProcessId = sigar.getPid();

private final OperatingSystem operatingSystem;
private final int currentProcessId;
private final KeyedDiff diff = new KeyedDiff();
private OSProcess previousProcess;

public JvmCpuMonitor()
{
this(DEFAULT_METRICS_FEED);
}

public JvmCpuMonitor(String feed)
{
this(feed, new SystemInfo().getOperatingSystem());
}

@VisibleForTesting
JvmCpuMonitor(String feed, OperatingSystem operatingSystem)
{
super(feed);
this.operatingSystem = operatingSystem;
this.currentProcessId = operatingSystem.getProcessId();
this.previousProcess = operatingSystem.getProcess(currentProcessId);
}

@Override
public boolean doMonitor(ServiceEmitter emitter)
{
// process CPU
try {
ProcCpu procCpu = sigar.getProcCpu(currentProcessId);
final ServiceMetricEvent.Builder builder = builder();
// delta for total, sys, user
Map<String, Long> procDiff = diff.to(
"proc/cpu", ImmutableMap.of(
"jvm/cpu/total", procCpu.getTotal(),
"jvm/cpu/sys", procCpu.getSys(),
"jvm/cpu/user", procCpu.getUser()
)
);
if (procDiff != null) {
for (Map.Entry<String, Long> entry : procDiff.entrySet()) {
emitter.emit(builder.setMetric(entry.getKey(), entry.getValue()));
}
// Use getProcess() instead of getCurrentProcess() so lookup failures return null rather than a zero-valued
// CurrentProcessStub, which would corrupt the CPU deltas and previous-process baseline.
final OSProcess currentProcess = operatingSystem.getProcess(currentProcessId);
if (currentProcess == null) {
log.error("Unable to get current process CPU metrics");
return true;
}

final ServiceMetricEvent.Builder builder = builder();
final long userTime = currentProcess.getUserTime();
final long sysTime = currentProcess.getKernelTime();
final Map<String, Long> procDiff = diff.to(

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Do not advance the diff on failed OSHI snapshots

OperatingSystem.getCurrentProcess() is non-null by contract: when the native lookup fails it returns a CurrentProcessStub with zero or unknown fields. Because this code only checks for null, that stub is fed into KeyedDiff and then stored as previousProcess, emitting bogus zero deltas and making the next successful sample compare against the zero snapshot. Detect an invalid snapshot and leave the diff and previous-process state unchanged when OSHI cannot read the process.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in the latest commit. JvmCpuMonitor now uses the nullable OperatingSystem.getProcess(pid) API, so a failed lookup is skipped before either KeyedDiff or previousProcess is updated. This prevents failed snapshots from producing bogus deltas or poisoning the next CPU percentage calculation.

Added a regression test covering a valid snapshot, a failed lookup, and the next valid snapshot; the original baselines are preserved.

Validation: 16 focused processing tests passed; Checkstyle reported 0 violations.

Reviewed 2 of 2 affected files.

"proc/cpu", ImmutableMap.of(
"jvm/cpu/total", userTime + sysTime,
"jvm/cpu/sys", sysTime,
"jvm/cpu/user", userTime
)
);
if (procDiff != null) {
for (Map.Entry<String, Long> entry : procDiff.entrySet()) {
emitter.emit(builder.setMetric(entry.getKey(), entry.getValue()));
}
emitter.emit(builder.setMetric("jvm/cpu/percent", procCpu.getPercent()));
}
catch (SigarException e) {
log.error(e, "Failed to get ProcCpu");

final double cpuLoad = currentProcess.getProcessCpuLoadBetweenTicks(previousProcess);
if (cpuLoad >= 0) {
emitter.emit(builder.setMetric("jvm/cpu/percent", cpuLoad * 100));
}

previousProcess = currentProcess;
return true;
}
}
Loading
Loading