Merge pull request #3248 from dgrove727/3173_DisplayDataSourceSizeMetrics

3173 display data source size metrics
This commit is contained in:
Richard Cordovano 2017-12-01 13:12:18 -05:00 committed by GitHub
commit 06cd80c4f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 136 additions and 67 deletions

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2011-2017 Basis Technology Corp. * Copyright 2017 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -29,14 +29,15 @@ import org.sleuthkit.autopsy.coreutils.Logger;
* Collects metrics for an auto ingest cluster. * Collects metrics for an auto ingest cluster.
*/ */
final class AutoIngestMetricsCollector { final class AutoIngestMetricsCollector {
private static final Logger LOGGER = Logger.getLogger(AutoIngestMetricsCollector.class.getName()); private static final Logger LOGGER = Logger.getLogger(AutoIngestMetricsCollector.class.getName());
private static final int MINIMUM_SUPPORTED_JOB_NODE_VERSION = 1;
private CoordinationService coordinationService; private CoordinationService coordinationService;
/** /**
* Creates an instance of the AutoIngestMetricsCollector. * Creates an instance of the AutoIngestMetricsCollector.
* *
* @throws AutoIngestMetricsCollector.AutoIngestMetricsCollectorException * @throws AutoIngestMetricsCollector.AutoIngestMetricsCollectorException
*/ */
AutoIngestMetricsCollector() throws AutoIngestMetricsCollectorException { AutoIngestMetricsCollector() throws AutoIngestMetricsCollectorException {
try { try {
@ -45,7 +46,7 @@ final class AutoIngestMetricsCollector {
throw new AutoIngestMetricsCollectorException("Failed to get coordination service", ex); //NON-NLS throw new AutoIngestMetricsCollectorException("Failed to get coordination service", ex); //NON-NLS
} }
} }
/** /**
* Gets a new metrics snapshot from the coordination service for an auto * Gets a new metrics snapshot from the coordination service for an auto
* ingest cluster. * ingest cluster.
@ -59,7 +60,7 @@ final class AutoIngestMetricsCollector {
for (String node : nodeList) { for (String node : nodeList) {
try { try {
AutoIngestJobNodeData nodeData = new AutoIngestJobNodeData(coordinationService.getNodeData(CoordinationService.CategoryNode.MANIFESTS, node)); AutoIngestJobNodeData nodeData = new AutoIngestJobNodeData(coordinationService.getNodeData(CoordinationService.CategoryNode.MANIFESTS, node));
if (nodeData.getVersion() < 1) { if (nodeData.getVersion() < MINIMUM_SUPPORTED_JOB_NODE_VERSION) {
/* /*
* Ignore version '0' nodes that have not been * Ignore version '0' nodes that have not been
* "upgraded" since they don't carry enough data. * "upgraded" since they don't carry enough data.
@ -78,7 +79,7 @@ final class AutoIngestMetricsCollector {
*/ */
break; break;
case COMPLETED: case COMPLETED:
newMetricsSnapshot.addCompletedJobDate(job.getCompletedDate()); newMetricsSnapshot.addCompletedJobMetric(job.getCompletedDate(), job.getDataSourceSize());
break; break;
default: default:
LOGGER.log(Level.SEVERE, "Unknown AutoIngestJobData.ProcessingStatus"); LOGGER.log(Level.SEVERE, "Unknown AutoIngestJobData.ProcessingStatus");
@ -92,41 +93,80 @@ final class AutoIngestMetricsCollector {
LOGGER.log(Level.SEVERE, String.format("Failed to create a job for '%s'", node), ex); LOGGER.log(Level.SEVERE, String.format("Failed to create a job for '%s'", node), ex);
} }
} }
return newMetricsSnapshot; return newMetricsSnapshot;
} catch (CoordinationService.CoordinationServiceException ex) { } catch (CoordinationService.CoordinationServiceException ex) {
LOGGER.log(Level.SEVERE, "Failed to get node list from coordination service", ex); LOGGER.log(Level.SEVERE, "Failed to get node list from coordination service", ex);
return new MetricsSnapshot(); return new MetricsSnapshot();
} }
} }
/** /**
* A snapshot of metrics for an auto ingest cluster. * A snapshot of metrics for an auto ingest cluster.
*/ */
static final class MetricsSnapshot { static final class MetricsSnapshot {
private final List<Long> completedJobDates = new ArrayList<>(); private final List<JobMetric> completedJobMetrics = new ArrayList<>();
/** /**
* Gets a list of completed job dates, formatted in milliseconds. * Gets a list of completed job metrics.
* *
* @return The completed job dates, formatted in milliseconds. * @return The completed job metrics.
*/ */
List<Long> getCompletedJobDates() { List<JobMetric> getCompletedJobMetrics() {
return new ArrayList<>(completedJobDates); return new ArrayList<>(completedJobMetrics);
} }
/** /**
* Adds a new date to the list of completed job dates. * Adds a new metric to the list of completed job metrics.
* *
* @param date The date to be added. * @param completedDate The completed job date.
* @param dataSourceSize The data source size.
*/ */
void addCompletedJobDate(java.util.Date date) { void addCompletedJobMetric(java.util.Date completedDate, long dataSourceSize) {
completedJobDates.add(date.getTime()); completedJobMetrics.add(new JobMetric(completedDate, dataSourceSize));
} }
} }
/**
* A single job metric for an auto ingest cluster.
*/
static final class JobMetric {
private final long completedDate;
private final long dataSourceSize;
/**
* Instantiates a job metric.
*
* @param completedDate The job completion date.
* @param dataSourceSize The data source size.
*/
JobMetric(java.util.Date completedDate, long dataSourceSize) {
this.completedDate = completedDate.getTime();
this.dataSourceSize = dataSourceSize;
}
/**
* Gets the job completion date, formatted in milliseconds.
*
* @return The job completion date.
*/
long getCompletedDate() {
return completedDate;
}
/**
* Gets the data source size.
*
* @return The data source size.
*/
long getDataSourceSize() {
return dataSourceSize;
}
}
/** /**
* Exception type thrown when there is an error completing an auto ingest * Exception type thrown when there is an error completing an auto ingest
* metrics collector operation. * metrics collector operation.
@ -157,4 +197,4 @@ final class AutoIngestMetricsCollector {
} }
} }
} }

View File

@ -30,10 +30,14 @@
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="jScrollPane1" alignment="0" max="32767" attributes="0"/> <Component id="jScrollPane1" alignment="0" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<Component id="metricsButton" min="-2" max="-2" attributes="0"/> <Component id="startingDataLabel" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="datePicker" min="-2" max="-2" attributes="0"/> <Component id="datePicker" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="33" max="32767" attributes="0"/> <EmptySpace pref="7" max="32767" attributes="0"/>
<Component id="metricsButton" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Component id="closeButton" min="-2" pref="70" max="-2" attributes="0"/> <Component id="closeButton" min="-2" pref="70" max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
@ -43,17 +47,17 @@
</DimensionLayout> </DimensionLayout>
<DimensionLayout dim="1"> <DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0"> <Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="metricsButton" min="-2" max="-2" attributes="0"/>
<Component id="datePicker" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="startingDataLabel" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jScrollPane1" min="-2" pref="128" max="-2" attributes="0"/> <Component id="jScrollPane1" min="-2" pref="128" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/> <EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0"> <Component id="closeButton" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="closeButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="metricsButton" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="datePicker" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/> <EmptySpace max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
@ -109,5 +113,12 @@
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new DatePicker();"/> <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new DatePicker();"/>
</AuxValues> </AuxValues>
</Component> </Component>
<Component class="javax.swing.JLabel" name="startingDataLabel">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/experimental/autoingest/Bundle.properties" key="AutoIngestMetricsDialog.startingDataLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
</SubComponents> </SubComponents>
</Form> </Form>

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2011-2017 Basis Technology Corp. * Copyright 2017 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -25,24 +25,28 @@ import java.awt.Window;
import java.sql.Date; import java.sql.Date;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.ZoneOffset; import java.time.ZoneOffset;
import java.util.List;
import org.openide.util.NbBundle; import org.openide.util.NbBundle;
import org.openide.util.NbBundle.Messages; import org.openide.util.NbBundle.Messages;
import org.sleuthkit.autopsy.experimental.autoingest.AutoIngestMetricsCollector.JobMetric;
/** /**
* Displays auto ingest metrics for a cluster. * Displays auto ingest metrics for a cluster.
*/ */
final class AutoIngestMetricsDialog extends javax.swing.JDialog { final class AutoIngestMetricsDialog extends javax.swing.JDialog {
private static final int GIGABYTE_SIZE = 1073741824;
private final AutoIngestMetricsCollector autoIngestMetricsCollector; private final AutoIngestMetricsCollector autoIngestMetricsCollector;
/** /**
* Creates an instance of AutoIngestMetricsDialog * Creates an instance of AutoIngestMetricsDialog
* *
* @param parent The parent container. * @param parent The parent container.
*/ */
@Messages({ @Messages({
"AutoIngestMetricsDialog.title.text=Auto Ingest Cluster Metrics", "AutoIngestMetricsDialog.title.text=Auto Ingest Cluster Metrics",
"AutoIngestMetricsDialog.initReportText=Select a date below and click the 'Get Metrics Since...' button to generate\na metrics report." "AutoIngestMetricsDialog.initReportText=Select a date above and click the 'Generate Metrics Report' button to generate\na metrics report."
}) })
AutoIngestMetricsDialog(Container parent) throws AutoIngestMetricsDialogException { AutoIngestMetricsDialog(Container parent) throws AutoIngestMetricsDialogException {
super((Window) parent, NbBundle.getMessage(AutoIngestMetricsDialog.class, "AutoIngestMetricsDialog.title.text"), ModalityType.MODELESS); super((Window) parent, NbBundle.getMessage(AutoIngestMetricsDialog.class, "AutoIngestMetricsDialog.title.text"), ModalityType.MODELESS);
@ -58,34 +62,39 @@ final class AutoIngestMetricsDialog extends javax.swing.JDialog {
setLocationRelativeTo(parent); setLocationRelativeTo(parent);
setVisible(true); setVisible(true);
} }
/** /**
* Update the metrics shown in the report text area. * Update the metrics shown in the report text area.
*/ */
private void updateMetrics() { private void updateMetrics() {
if(datePicker.getDate() == null) { if (datePicker.getDate() == null) {
return; return;
} }
AutoIngestMetricsCollector.MetricsSnapshot metricsSnapshot = autoIngestMetricsCollector.queryCoordinationServiceForMetrics(); AutoIngestMetricsCollector.MetricsSnapshot metricsSnapshot = autoIngestMetricsCollector.queryCoordinationServiceForMetrics();
Object[] completedJobDates = metricsSnapshot.getCompletedJobDates().toArray(); List<JobMetric> completedJobMetrics = metricsSnapshot.getCompletedJobMetrics();
int count = 0; int jobsCompleted = 0;
long dataSourceSizeTotal = 0;
long pickedDate = datePicker.getDate().atStartOfDay().toEpochSecond(ZoneOffset.UTC) * 1000; long pickedDate = datePicker.getDate().atStartOfDay().toEpochSecond(ZoneOffset.UTC) * 1000;
for(int i = completedJobDates.length - 1; i >= 0; i--) {
if((Long)completedJobDates[i] >= pickedDate) { for (JobMetric jobMetric : completedJobMetrics) {
count++; if (jobMetric.getCompletedDate() >= pickedDate) {
jobsCompleted++;
dataSourceSizeTotal += jobMetric.getDataSourceSize();
} }
} }
SimpleDateFormat dateFormatter = new SimpleDateFormat("MMM d, yyyy"); SimpleDateFormat dateFormatter = new SimpleDateFormat("MMM d, yyyy");
reportTextArea.setText(String.format( reportTextArea.setText(String.format(
"Since %s:\n" + "Since %s:\n"
"\tNumber of Jobs Completed: %d\n", + "Number of Jobs Completed: %d\n"
+ "Total Size of Data Sources: %.1f GB\n",
dateFormatter.format(Date.valueOf(datePicker.getDate())), dateFormatter.format(Date.valueOf(datePicker.getDate())),
count jobsCompleted,
(double) dataSourceSizeTotal / GIGABYTE_SIZE
)); ));
} }
/** /**
* Exception type thrown when there is an error completing an auto ingest * Exception type thrown when there is an error completing an auto ingest
* metrics dialog operation. * metrics dialog operation.
@ -131,6 +140,7 @@ final class AutoIngestMetricsDialog extends javax.swing.JDialog {
reportTextArea = new javax.swing.JTextArea(); reportTextArea = new javax.swing.JTextArea();
metricsButton = new javax.swing.JButton(); metricsButton = new javax.swing.JButton();
datePicker = new DatePicker(); datePicker = new DatePicker();
startingDataLabel = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setAlwaysOnTop(true); setAlwaysOnTop(true);
@ -158,6 +168,8 @@ final class AutoIngestMetricsDialog extends javax.swing.JDialog {
datePicker.setToolTipText(org.openide.util.NbBundle.getMessage(AutoIngestMetricsDialog.class, "AutoIngestMetricsDialog.datePicker.toolTipText")); // NOI18N datePicker.setToolTipText(org.openide.util.NbBundle.getMessage(AutoIngestMetricsDialog.class, "AutoIngestMetricsDialog.datePicker.toolTipText")); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(startingDataLabel, org.openide.util.NbBundle.getMessage(AutoIngestMetricsDialog.class, "AutoIngestMetricsDialog.startingDataLabel.text")); // NOI18N
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout); getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.setHorizontalGroup(
@ -167,24 +179,28 @@ final class AutoIngestMetricsDialog extends javax.swing.JDialog {
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1) .addComponent(jScrollPane1)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addComponent(metricsButton) .addComponent(startingDataLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(datePicker, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(datePicker, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 33, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 7, Short.MAX_VALUE)
.addComponent(metricsButton))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(closeButton, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE))) .addComponent(closeButton, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap()) .addContainerGap())
); );
layout.setVerticalGroup( layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(metricsButton)
.addComponent(datePicker, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(startingDataLabel))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(closeButton)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(closeButton)
.addComponent(metricsButton))
.addComponent(datePicker, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
); );
@ -208,5 +224,6 @@ final class AutoIngestMetricsDialog extends javax.swing.JDialog {
private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JButton metricsButton; private javax.swing.JButton metricsButton;
private javax.swing.JTextArea reportTextArea; private javax.swing.JTextArea reportTextArea;
private javax.swing.JLabel startingDataLabel;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables
} }

View File

@ -228,10 +228,11 @@ AutoIngestDashboard.prioritizeCaseButton.toolTipText=Move all images associated
AutoIngestDashboard.prioritizeCaseButton.text=Prioritize &Case AutoIngestDashboard.prioritizeCaseButton.text=Prioritize &Case
AutoIngestMetricsDialog.reportTextArea.text= AutoIngestMetricsDialog.reportTextArea.text=
AutoIngestDashboard.clusterMetricsButton.text=Cluster Metrics AutoIngestDashboard.clusterMetricsButton.text=Cluster Metrics
AutoIngestMetricsDialog.metricsButton.text=Get Metrics Since... AutoIngestMetricsDialog.metricsButton.text=Generate Metrics Report
AutoIngestMetricsDialog.closeButton.text=Close AutoIngestMetricsDialog.closeButton.text=Close
AutoIngestMetricsDialog.datePicker.toolTipText=Choose a date AutoIngestMetricsDialog.datePicker.toolTipText=Choose a date
ArchiveFilePanel.pathLabel.text=Browse for an archive file: ArchiveFilePanel.pathLabel.text=Browse for an archive file:
ArchiveFilePanel.browseButton.text=Browse ArchiveFilePanel.browseButton.text=Browse
ArchiveFilePanel.pathTextField.text= ArchiveFilePanel.pathTextField.text=
ArchiveFilePanel.errorLabel.text=Error Label ArchiveFilePanel.errorLabel.text=Error Label
AutoIngestMetricsDialog.startingDataLabel.text=Starting Date: