---
title: How to Clear the Swimlane Usage Metrics
slug: user-guide-10x/how-to-clear-the-swimlane-usage-metrics
docTags: 
createdAt: 2025-12-12T11:58:02.493Z
---

Resetting the Swimlane Usage Metrics is available in the Swimlane Health & Maintenance Operations Application. However, having the following manual method to reset the data using a Python script is also helpful when troubleshooting.

# Using MongoDB

Connect to the MongoDB using the mongo shell or a tool like Robo3T and run the following query:

:::BlockQuote
use Swimlane;
db.UsageEntryAggregates.remove(\{})
:::

# Using Python Script

## Description

Create the following Script Inputs in your task:

:::BlockQuote
swimlane\_api\_pat
mongoServer
mongoPort
mongoUser # For the Swimlane database
mongoPass # For the Swimlane database
database = Swimlane
collection = UsageEntryAggregates
task = Reset Usage Metrics
:::

NOTE: For a standalone deployment, remove line number 16 below from the code (replicaSet='rs0',)

:::BlockQuote
from pymongo import MongoClient
from swimlane import Swimlane
import pendulum
import ssl

\#connect to Swimlane:
swimlane = Swimlane(sw\_context.config\['InternalSwimlaneUrl'], access\_token=sw\_context.inputs\['swimlane\_api\_pat'], verify\_ssl=False)

\#Connect to Mongo:
def connect\_to\_mongo(swimlane\_auth\_source):
&#x20;   connectionParams = MongoClient(host=sw\_context.inputs\['mongoServer'],
&#x20;                                  port=int(sw\_context.inputs\['mongoPort']),
&#x20;                                  username=sw\_context.inputs\['mongoUser'],
&#x20;                                  password=sw\_context.inputs\['mongoPass'],
&#x20;                                  authSource=swimlane\_auth\_source,
&#x20;                                  replicaSet='rs0',
&#x20;                                  authMechanism='SCRAM-SHA-1',
&#x20;                                  ssl=True,
&#x20;                                  ssl\_cert\_reqs=ssl.CERT\_NONE)
&#x20;   return connectionParams

\#Set Database & Auth to Swimlane or SwimlaneHistory from Workflow Action Set Field
swimlane\_auth\_source = swimlane\_database = sw\_context.inputs\['database']

\#Retrieve Collection from Workflow Action Set Field
collection\_name = sw\_context.inputs\['collection']

try:
&#x20;   if swimlane\_auth\_source and collection\_name and sw\_context.inputs\['task'] == 'Reset Usage Metrics':
&#x20;     db = connect\_to\_mongo(swimlane\_auth\_source)\[swimlane\_database]
&#x20;     collection = db\[collection\_name]
&#x20;     resetUsageMetrics = collection.delete\_many(\{})
&#x20;     sw\_outputs = \[\{'deleted\_count': resetUsageMetrics.deleted\_count}]
except Exception as e:
&#x20; print(e)
:::

