Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
atlas
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dataplatform
atlas
Commits
5dffddd0
Commit
5dffddd0
authored
Oct 04, 2019
by
nikhilbonte
Committed by
kevalbhatt
Oct 09, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-3441 Add JVM resource metrics for Atlas monitoring
Signed-off-by:
kevalbhatt
<
kbhatt@apache.org
>
parent
adfc526e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
119 additions
and
0 deletions
+119
-0
MetricsService.java
...c/main/java/org/apache/atlas/services/MetricsService.java
+8
-0
AtlasMetricJVMUtil.java
...c/main/java/org/apache/atlas/util/AtlasMetricJVMUtil.java
+111
-0
No files found.
repository/src/main/java/org/apache/atlas/services/MetricsService.java
View file @
5dffddd0
...
...
@@ -27,6 +27,7 @@ import org.apache.atlas.repository.graphdb.AtlasVertex;
import
org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2
;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.apache.atlas.util.AtlasMetricsUtil
;
import
org.apache.atlas.util.AtlasMetricJVMUtil
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -50,6 +51,7 @@ public class MetricsService {
public
static
final
String
ENTITY
=
"entity"
;
public
static
final
String
TAG
=
"tag"
;
public
static
final
String
GENERAL
=
"general"
;
public
static
final
String
SYSTEM
=
"system"
;
// Query names
protected
static
final
String
METRIC_COLLECTION_TIME
=
"collectionTime"
;
...
...
@@ -62,6 +64,9 @@ public class MetricsService {
protected
static
final
String
METRIC_ENTITY_SHELL
=
ENTITY
+
"Shell"
;
protected
static
final
String
METRIC_TAG_COUNT
=
TAG
+
"Count"
;
protected
static
final
String
METRIC_ENTITIES_PER_TAG
=
TAG
+
"Entities"
;
protected
static
final
String
METRIC_RUNTIME
=
"runtime"
;
protected
static
final
String
METRIC_MEMORY
=
"memory"
;
protected
static
final
String
METRIC_OS
=
"os"
;
private
final
AtlasGraph
atlasGraph
;
private
final
AtlasTypeRegistry
typeRegistry
;
...
...
@@ -131,6 +136,9 @@ public class MetricsService {
metrics
.
addMetric
(
ENTITY
,
METRIC_ENTITY_SHELL
,
getShellEntityCount
());
metrics
.
addMetric
(
TAG
,
METRIC_ENTITIES_PER_TAG
,
taggedEntityCount
);
metrics
.
addMetric
(
SYSTEM
,
METRIC_MEMORY
,
AtlasMetricJVMUtil
.
getMemoryDetails
());
metrics
.
addMetric
(
SYSTEM
,
METRIC_OS
,
AtlasMetricJVMUtil
.
getSystemInfo
());
metrics
.
addMetric
(
SYSTEM
,
METRIC_RUNTIME
,
AtlasMetricJVMUtil
.
getRuntimeInfo
());
return
metrics
;
}
...
...
repository/src/main/java/org/apache/atlas/util/AtlasMetricJVMUtil.java
0 → 100644
View file @
5dffddd0
/*
* 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
.
atlas
.
util
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.lang.management.ManagementFactory
;
import
java.lang.management.MemoryMXBean
;
import
java.lang.management.MemoryPoolMXBean
;
import
java.lang.management.MemoryType
;
import
java.lang.management.MemoryUsage
;
import
java.lang.management.OperatingSystemMXBean
;
import
java.lang.management.RuntimeMXBean
;
import
java.util.Arrays
;
import
java.util.Collection
;
import
java.util.Iterator
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
java.util.Objects
;
public
class
AtlasMetricJVMUtil
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
AtlasMetricJVMUtil
.
class
);
private
static
final
RuntimeMXBean
RUNTIME
;
private
static
final
OperatingSystemMXBean
OS
;
private
static
final
MemoryMXBean
memBean
;
static
{
RUNTIME
=
ManagementFactory
.
getRuntimeMXBean
();
OS
=
ManagementFactory
.
getOperatingSystemMXBean
();
memBean
=
ManagementFactory
.
getMemoryMXBean
();
}
/**
* Collect general runtime information.
*/
public
static
Map
<
String
,
Object
>
getRuntimeInfo
()
{
Map
<
String
,
Object
>
vmDetails
=
new
LinkedHashMap
<>();
vmDetails
.
put
(
"name"
,
RUNTIME
.
getVmName
());
vmDetails
.
put
(
"version"
,
RUNTIME
.
getSystemProperties
().
get
(
"java.version"
));
return
vmDetails
;
}
/**
* Add memory details
*/
public
static
Map
<
String
,
Object
>
getMemoryDetails
()
{
Map
<
String
,
Object
>
memory
=
new
LinkedHashMap
<>();
heapDetails
(
memory
);
pooldivision
(
memory
);
return
memory
;
}
/**
* Collect system information.
*/
public
static
Map
<
String
,
Object
>
getSystemInfo
()
{
Map
<
String
,
Object
>
values
=
new
LinkedHashMap
<>();
String
[]
osInfo
=
{
OS
.
getName
(),
OS
.
getArch
(),
OS
.
getVersion
()};
values
.
put
(
"os.spec"
,
String
.
join
(
", "
,
osInfo
));
values
.
put
(
"os.vcpus"
,
String
.
valueOf
(
OS
.
getAvailableProcessors
()));
return
values
;
}
/**
* collect the pool division of java
*/
private
static
void
pooldivision
(
Map
<
String
,
Object
>
memory
)
{
Map
<
String
,
Object
>
poolDivisionValues
=
new
LinkedHashMap
<>();
for
(
MemoryPoolMXBean
mpBean
:
ManagementFactory
.
getMemoryPoolMXBeans
())
{
if
(
mpBean
.
getType
()
==
MemoryType
.
HEAP
)
{
poolDivisionValues
.
put
(
mpBean
.
getName
(),
mpBean
.
getUsage
());
}
}
memory
.
put
(
"memory_pool_usages"
,
poolDivisionValues
);
}
/**
* Collect java heap details
*/
private
static
void
heapDetails
(
Map
<
String
,
Object
>
memory
)
{
MemoryUsage
memHeapUsage
=
memBean
.
getHeapMemoryUsage
();
MemoryUsage
nonHeapUsage
=
memBean
.
getNonHeapMemoryUsage
();
memory
.
put
(
"heapInit"
,
String
.
valueOf
(
memHeapUsage
.
getInit
()));
memory
.
put
(
"heapMax"
,
String
.
valueOf
(
memHeapUsage
.
getMax
()));
memory
.
put
(
"heapCommitted"
,
String
.
valueOf
(
memHeapUsage
.
getCommitted
()));
memory
.
put
(
"heapUsed"
,
String
.
valueOf
(
memHeapUsage
.
getUsed
()));
memory
.
put
(
"nonHeapInit"
,
String
.
valueOf
(
nonHeapUsage
.
getInit
()));
memory
.
put
(
"nonHeapMax"
,
String
.
valueOf
(
nonHeapUsage
.
getMax
()));
memory
.
put
(
"nonHeapCommitted"
,
String
.
valueOf
(
nonHeapUsage
.
getCommitted
()));
memory
.
put
(
"nonHeapUsed"
,
String
.
valueOf
(
nonHeapUsage
.
getUsed
()));
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment