Monitoring and Auditing Web Console Activity
You can use the EVT_MANAGEMENT_TASK_STARTED event to track user activity performed in Visor or Web Console (actions performed directly via Java/C++/.NET or the various thin clients are tracked elsewhere). Here’s a list of the available tasks it tracks.
Enabling Cluster Auditing
-
Enable the
EVT_MANAGEMENT_TASK_STARTEDevent type:<property name="includeEventTypes"> <list> <util:constant static-field="org.apache.ignite.events.EventType.EVT_MANAGEMENT_TASK_STARTED"/> </list> </property> -
Implement
EventStorageSpi. The implementation will receive all events in itsrecord()method. After that you can log or store the events however you prefer. -
Specify your
EventStorageSpiin the Ignite configuration:<property name="eventStorageSpi"> <!-- Insert the name of your implementation here. --> <bean class="org.gridgain.examples.events.MgmtAuditEventStorageSpi"/> </property>
Example EventStorageSpi Implementation
Here is a simple EventStorageSpi that ignores all events except EVT_MANAGEMENT_TASK_STARTED.
It doesn’t store the events anywhere, it just writes them to the log.
Note how this implementation extends IgniteSpiAdapter. This is to get access to the call getSpiContext().authenticatedSubject(…) which is used to convert the subject ID into a human-readable username in the login= field in the events.
public class MgmtAuditEventStorageSpi extends IgniteSpiAdapter implements EventStorageSpi {
@LoggerResource
private IgniteLogger log;
@Override
public <T extends Event> Collection<T> localEvents(IgnitePredicate<T> p) {
return null;
}
@Override
public void record(Event evt) throws IgniteSpiException {
if (evt.type() == EVT_MANAGEMENT_TASK_STARTED) {
TaskEvent taskEvent = (TaskEvent) evt;
SecuritySubject subj = taskEvent.subjectId() != null
? getSpiContext().authenticatedSubject(taskEvent.subjectId())
: null;
log.info("Management task started: [" +
"name=" + taskEvent.taskName() + ", " +
"eventNode=" + taskEvent.node() + ", " +
"timestamp=" + taskEvent.timestamp() + ", " +
"info=" + taskEvent.message() + ", " +
"subjectId=" + taskEvent.subjectId() + ", " +
"secureSubject=" + subj +
"]");
}
}
@Override
public void spiStart(@Nullable String igniteInstanceName) throws IgniteSpiException {
/* No-op. */
}
@Override
public void spiStop() throws IgniteSpiException {
/* No-op. */
}
}
Example Output
In the following examples, you can see the task name at the beginning of each output: name=, and the username at the end: login=.
[2019-08-01 12:09:34,386][INFO ][rest-#66][MgmtAuditEventStorageSpi] Management task started:
[name=VisorThreadDumpTask, eventNode=TcpDiscoveryNode
[id=a2039eff, consistentId=0:0:0:0:0:0:0:1%lo0,127.0.0.1,172.2.6.7:47501,
addrs=ArrayList [0:0:0:0:0:0:0:1%lo0, 127.0.0.1, 172.2.6.7],
sockAddrs=HashSet [/0:0:0:0:0:0:0:1%lo0:47501, /127.0.0.1:47501,
example.gridgain.local/172.2.6.7:47501], discPort=47501, order=2,
intOrder=2, lastExchangeTime=1564650459177, loc=true,
ver=2.5.6#20190801-sha1:00000000, isClient=false], timestamp=1564650574377,
info=[], subjectId=722a617a, secureSubject=SecuritySubjectAdapter
[id=722a617a, subjType=REMOTE_CLIENT, addr=/127.0.0.1:54321,
permissions=SecurityPermissionsUnmodifiableSet [dfltAllowAll=true,
taskPermissions=LinkedHashMap {}, cachePermissions=LinkedHashMap {},
sysPermissions=null, srvcPerms=HashMap {}], login=exampleUser]]
[2019-08-01 12:08:09,399][INFO ][rest-#66][MgmtAuditEventStorageSpi] Management task started:
[name=VisorNodePingTask, eventNode=TcpDiscoveryNode [id=a2039eff,
consistentId=0:0:0:0:0:0:0:1%lo0,127.0.0.1,172.2.6.7:47501, addrs=ArrayList
[0:0:0:0:0:0:0:1%lo0, 127.0.0.1, 172.2.6.7], sockAddrs=HashSet
[/0:0:0:0:0:0:0:1%lo0:47501, /127.0.0.1:47501,
example.gridgain.local/172.2.6.7:47501], discPort=47501, order=2, intOrder=2,
lastExchangeTime=1564650459177, loc=true, ver=2.5.6#20190801-sha1:00000000,
isClient=false], timestamp=1564650489396, info=VisorNodePingTaskArg
[nodeId=a2039eff], subjectId=722a617a, secureSubject=SecuritySubjectAdapter
[id=722a617a, subjType=REMOTE_CLIENT, addr=/127.0.0.1:54321,
permissions=SecurityPermissionsUnmodifiableSet [dfltAllowAll=true,
taskPermissions=LinkedHashMap {}, cachePermissions=LinkedHashMap {},
sysPermissions=null, srvcPerms=HashMap {}], login=exampleUser]]
[2019-08-01 12:10:27,591][INFO ][rest-#70][MgmtAuditEventStorageSpi] Management task started:
[name=VisorQueryTask, eventNode=TcpDiscoveryNode [id=a2039eff,
consistentId=0:0:0:0:0:0:0:1%lo0,127.0.0.1,172.2.6.7:47501, addrs=ArrayList
[0:0:0:0:0:0:0:1%lo0, 127.0.0.1, 172.2.6.7], sockAddrs=HashSet
[/0:0:0:0:0:0:0:1%lo0:47501, /127.0.0.1:47501,
example.gridgain.local/172.2.6.7:47501], discPort=47501, order=2, intOrder=2,
lastExchangeTime=1564650459177, loc=true, ver=2.5.6#20190801-sha1:00000000,
isClient=false], timestamp=1564650627585, info=VisorQueryTaskArg
[cacheName=null, qryTxt=SELECT * FROM CACHE, distributedJoins=false,
enforceJoinOrder=false, replicatedOnly=false, loc=false, pageSize=100,
lazy=true, collocated=false], subjectId=722a617a,
secureSubject=SecuritySubjectAdapter [id=722a617a, subjType=REMOTE_CLIENT,
addr=/127.0.0.1:54321, permissions=SecurityPermissionsUnmodifiableSet
[dfltAllowAll=true, taskPermissions=LinkedHashMap {},
cachePermissions=LinkedHashMap {}, sysPermissions=null,
srvcPerms=HashMap {}], login=exampleUser]]
Available Tasks
EVT_MANAGEMENT_TASK_STARTED tracks the following tasks:
| Category | Task | Description |
|---|---|---|
Baseline |
|
Collects information about baseline topology and can change its state. |
Binaries |
|
Collects binary metadata. |
Services |
|
Cancels services with the specified name. |
Metrics |
|
Cancels services with specified name. |
Caches |
|
Collects list of lost partitions. |
|
Resets lost partitions for caches. |
|
|
Starts cache or near cache with the specified configuration. |
|
|
Stops specified caches on the specified node. |
|
|
Finds affinity node for a key. |
|
|
Modifies the value in the specified cache. |
|
|
Pre-loads caches. Made callable just to confirm the common pattern. |
|
|
Loads caches. |
|
|
Clears specified caches on the specified node. |
|
Queries |
|
Resets compute grid query metrics. |
|
Executes SQL fields query and gets the first page of results. |
|
|
Cancels queries. |
|
Computes |
|
Resets compute grid metrics. |
|
Cancels given tasks sessions. |
|
DEBUG |
|
Creates a thread dump. |
IGFS |
|
Formats IGFS instance. |
|
Removes all IGFS profiler logs. |
|
|
Resets IGFS metrics. |
|
LOGS |
|
Searches for text matching in logs. |
CLUSTER |
|
Changes grid active state. |
|
Runs GC on nodes. |
|
|
Restarts nodes. |
|
|
Stops nodes. |
© 2021 GridGain Systems, Inc. All Rights Reserved. Privacy Policy | Legal Notices. GridGain® is a registered trademark of GridGain Systems, Inc.
Apache, Apache Ignite, the Apache feather and the Apache Ignite logo are either registered trademarks or trademarks of The Apache Software Foundation.