The countdown to Elevate 2026 is on. Join us in Chicago, London, or Sydney.

Register here

Partners

Docs

LM Academy

LM Community

Platform

Solutions

Pricing

Resources

Company

Platform
  • Infrastructure
  • Cloud & Multi-Cloud
  • Log Management
  • Edwin AI
Solution
  • Automation
  • Tool Consolidation
  • Reduce MTTR
  • Cost Optimization
Industry
  • Healthcare
  • Financial Services
  • Public Sector
  • MSP
Role
  • CIO
  • ITOps
  • CloudOps
  • AIOps
There is no result.
Try it free

14-day access to the full LogicMonitor platform

Explore Platform

One platform, one system for observability, intelligence, and action.

Agentic AIOps

Infrastructure Observability

Cloud Observability

Internet Performance Monitoring

Digital Experience Monitoring

Log Management

3000+ Integrations
3000+ Integrations

Agentic AIOps Overview

Autonomously detect, diagnose, and resolve issues across your environment.

Meet Edwin AI

Turn fragmented cross-domain event noise into explainable, guided action.

AI Agent

Deploy specialized AI agents to handle investigation across the incident lifecycle.

Event Intelligence

Compress raw alert storms into high-fidelity, prioritized insights.

AI Automation

Execute governed, closed-loop remediation across automation playbooks.

ITOps Context Graph

NEW

Unify topology, telemetry, and changes into an AI-ready context layer.

MCP

NEW

Establish traceable, secure governance boundaries for AI tool integrations.

Infrastructure Observability Overview

Full visibility across your entire hybrid estate to eliminate tool sprawl.

Network Monitoring

Accelerate time to innocence with deep network path and device visibility.

Server Monitoring

Track server health, OS metrics, and resource utilization across environments.

Remote Monitoring

Monitor distributed endpoints, branch networks, and remote facility health.

VM Monitoring

Maximize hypervisor performance and streamline compute capacity planning.

SD-WAN Monitoring

Keep multi-site cloud networks connected with real-time edge visibility.

Database Monitoring

Pinpoint database query bottlenecks to keep business applications fast.

Configuration Monitoring

Minimize change failure rates by tracking device configuration drift.

Storage Monitoring

Track SAN/NAS arrays, IOPS bottlenecks, and storage capacity trends.

Cloud Observability Overview

Multi-cloud and hybrid environments unified into a single operational pane.

Container Monitoring

Automated, real-time visibility for Kubernetes and ephemeral microservices.

AWS Monitoring

Track AWS services, scaling, and costs alongside on-premises data.

Google Cloud Monitoring

Monitor native GCP infrastructure, compute, and serverless resources.

Azure Monitoring

Comprehensive visibility into Azure environments, gateways, and workloads.

AI Monitoring

Track LLM infrastructure, GPU utilization, and AI application stack health.

Oracle Cloud Monitoring

Track OCI native compute, enterprise databases, and cloud storage.

SaaS Monitoring

Validate availability and workforce productivity for critical SaaS apps.

Internet Performance Monitoring Overview

Understand performance across the full stack wherever users depend on it.

Internet Health

NEW

Use global vantage points to independently validate internet outages.

Real User Monitoring

NEW

Capture actual customer journeys and frontend performance in real time.

Synthetic Monitoring

NEW

Emulate user transactions and SaaS workflows to catch problems early.

Endpoint Monitoring

NEW

Diagnose remote workforce digital experience across devices and networks.

Digital Experience Monitoring

See every dependency, regardless of ownership or location.

Website Monitoring

Protect revenue journeys with proactive synthetic checks and uptime tracking.

CDN Monitoring

NEW

Audit edge performance and latency variance across your CDN providers.

API Monitoring

NEW

Test endpoints and third-party API reliability for critical app integrations.

Application Performance Monitoring

Connect code execution and traces directly to infrastructure health.

DNS Monitoring

NEW

Speed up time-to-innocence by tracking global nameserver resolution times.

DevOps Lifecycle Monitoring

NEW

Protect release velocity by validating dependencies during deployments.

BGP Monitoring

NEW

Trace global routing changes and path leaks to secure internet reachability.

Log Management Overview

Centralize and correlate log data to resolve incidents before they escalate.

Log Analytics & Intelligence

Correlate contextual log data with metrics to speed up root-cause analysis.

WebPageTest Web Performance

Test, compare, and optimize website speed, Core Web Vitals, and performance across real devices and global locations.

Learn more
Explore Solutions

Proactively manage modern hybrid environments with predictive insights, intelligent automation, and full-stack observability.

By Business Outcome

By Role

By Industry

Professional Services

Autonomous IT

Predictive, autonomous IT built

for resilience.

Automation

Eliminate operational toil with safe, policy-governed remediation workflows.

Modernization and Transformation

Accelerate complex technology transitions while protecting core enterprise resilience.

Cloud Migration

Maintain workload performance throughout migration.

Tool Consolidation

Reduce licensing costs and silos by replacing fragmented monitoring tools.

Cost Optimization

Lower your total cost-to-serve by finding cloud waste and underused resources.

Operational Efficiency

Maximize team capacity by reducing alert storms and shift-handoff friction.

Reduce MTTR

Shorten war-rooms by surfacing topology-aware probable cause in mins.

Network Reachability

NEW

Independently audit external BGP, ISP, and SaaS provider connectivity boundaries.

Edge Deployment Optimization

NEW

Monitor SLOs, compare providers, and validate cloud and edge delivery.

Web Performance Optimization

NEW

Maximize digital checkout conversions by tracking global frontend latency metrics.

Application Resilience

NEW

Safeguard business services against transaction failures and costly downtime.

Workforce Productivity

NEW

Troubleshoot remote hardware and network issues to protect productivity.

CIO

Maximize enterprise resilience and align AI investments to measurable business ROI.

AIOps

Compress cross-domain event noise into explainable, automated ops leverage.

DevOps

Speed up releases by protecting engineering roadmaps from toil.

ITOps

Standardize incident response to reduce alert fatigue and after-hours work.

CloudOps

Unify multi-cloud visibility to optimize costs and track hybrid blast radius.

Healthcare

Protect continuity of care and EHR availability across clinical workflows.

Public Sector

Ensure mission continuity and audit readiness for citizen-facing services.

MSP

Protect service margins and scale ops using multi-tenant, AI-assisted triage.

Retail & E-commerce

Safeguard peak retail campaigns, POS uptime, and digital customer journeys.

Technology

Protect customer trust and engineering velocity with SLA-driven visibility.

Hospitality

Deliver frictionless guest experiences and keep booking engines online.

Education

Maintain always-on student portals, learning platforms, and campus networks.

Manufacturing

Prevent production downtime by unifying IT, OT-adjacent, and edge systems.

Financial Services

Secure transaction trust and meet strict resilience compliance requirements.

Why LogicMonitor?

Discover why leading IT teams trust us to unify hybrid observability and eliminate tool sprawl.

Learn more
Explore Resources

Check out our resource library for IT pros, featuring expert guides, strategies, and insights for smarter, AI-driven operations.

Resources

Upcoming Events

Platform Help

Blog

Insights and advice from the experts on all things observability and AI.

Case Studies

See what real users have to say about the LogicMonitor platform.

Webinars

Live and on-demand learning, all in one place.

IT Guides

Learn from expert guides on the topics that matter most to IT teams.

How We Compare

See how our platform stacks up against other solutions.

Viee of a bridge over a river leading to Cologne cathedral rising against the skyline and a blue sky
CONFERENCE

Digital X Cologne

September 8, 2026

Cologne

CONFERENCE

SWORD Day

September 17, 2026

Geneva

View all events

Join us at innovation-focused conferences, tech talks, webinars, and other events.

Support Docs

Access product docs, release notes, and support resources.

LM Community

Join the community to learn from peers, ask questions, and connect with experts.

Customer Education

Learn more about our platform through resources and live trainings.

2026 The Year of Autonomous IT

NEW

Discover the trends, benchmarks, and strategies driving the industry shift to Autonomous IT.

Read the report
About LogicMonitor

Our observability platform proactively delivers the insights and automation CIOs need to accelerate innovation.

Leadership

Meet the leaders building the future of observability and AI.

Our Customers

See the proof of how IT teams win with LogicMonitor.

Careers

Find job openings and learn about our employee benefits.

Newsroom

Stay current with our latest mentions, press releases, and events.

Culture

NEW

Join a collaborative, values-driven culture built on innovation and growth.

Security

Purpose-built security for the hybrid observability and AI era.

Contact & Locations

Connect with our experts to explore AI-powered observability solutions.

Sustainability

Our commitment to the environment and the people in it.

The countdown to Elevate 2026 is on. Join us in Chicago, London, or Sydney.

Register here
Try it free

Platform

Explore Platform

One platform, one system for observability, intelligence, and action.

Agentic AIOps

Infrastructure Observability

Cloud Observability

Internet Performance Monitoring

Digital Experience Monitoring

Log Management

3000+ Integrations

WebPageTest Web Performance

Test, compare, and optimize website speed, Core Web Vitals, and performance across real devices and global locations.

Solutions

Explore Solutions

Proactively manage modern hybrid environments with predictive insights, intelligent automation, and full-stack observability.

By Business Outcome

By Role

By Industry

Professional Services

Why LogicMonitor?

Discover why leading IT teams trust us to unify hybrid observability and eliminate tool sprawl.

Pricing

Resources

Explore Resources

Check out our resource library for IT pros, featuring expert guides, strategies, and insights for smarter, AI-driven operations.

Resources

Upcoming Events

Platform Help

NEW

2026 The Year of Autonomous IT

Discover the trends, benchmarks, and strategies driving the industry shift to Autonomous IT.

Company

About LogicMonitor

Our observability platform proactively delivers the insights and automation CIOs need to accelerate innovation.

Leadership

Meet the leaders building the future of observability and AI.

Careers

Find job openings and learn about our employee benefits.

Culture

NEW

Join a collaborative, values-driven culture built on innovation and growth.

Contact & Locations

Connect with our experts to explore AI-powered observability solutions.

Our Customers

See the proof of how IT teams win with LogicMonitor.

Newsroom

Stay current with our latest mentions, press releases, and events.

Security

Purpose-built security for the hybrid observability and AI era.

Sustainability

Our commitment to the environment and the people in it.

Partners

Docs

LM Academy

LM Community

Agentic AIOps

Agentic AIOps Overview

Autonomously detect, diagnose, and resolve issues across your environment.

Meet Edwin AI

Turn fragmented cross-domain event noise into explainable, guided action.

AI Agent

Deploy specialized AI agents to handle investigation across the incident lifecycle.

Event Intelligence

Compress raw alert storms into high-fidelity, prioritized insights.

AI Automation

Execute governed, closed-loop remediation across automation playbooks.

ITOps Context Graph

NEW

Unify topology, telemetry, and changes into an AI-ready context layer.

MCP

NEW

Establish traceable, secure governance boundaries for AI tool integrations.

Infrastructure Observability

Infrastructure Observability Overview

Full visibility across your entire hybrid estate to eliminate tool sprawl.

Network Monitoring

Accelerate time to innocence with deep network path and device visibility.

Server Monitoring

Track server health, OS metrics, and resource utilization across environments.

Remote Monitoring

Monitor distributed endpoints, branch networks, and remote facility health.

VM Monitoring

Maximize hypervisor performance and streamline compute capacity planning.

SD-WAN Monitoring

Keep multi-site cloud networks connected with real-time edge visibility.

Database Monitoring

Pinpoint database query bottlenecks to keep business applications fast.

Configuration Monitoring

Minimize change failure rates by tracking device configuration drift.

Storage Monitoring

Track SAN/NAS arrays, IOPS bottlenecks, and storage capacity trends.

Cloud Observability

Cloud Observability Overview

Multi-cloud and hybrid environments unified into a single operational pane.

Container Monitoring

Automated, real-time visibility for Kubernetes and ephemeral microservices.

AWS Monitoring

Track AWS services, scaling, and costs alongside on-premises data.

Google Cloud Monitoring

Monitor native GCP infrastructure, compute, and serverless resources.

Azure Monitoring

Comprehensive visibility into Azure environments, gateways, and workloads.

AI Monitoring

Track LLM infrastructure, GPU utilization, and AI application stack health.

Oracle Cloud Monitoring

Track OCI native compute, enterprise databases, and cloud storage.

SaaS Monitoring

Validate availability and workforce productivity for critical SaaS apps.

Internet Performance Monitoring

Internet Performance Monitoring Overview

Understand performance across the full stack wherever users depend on it.

Internet Health

NEW

Use global vantage points for independent validation of internet outages.

Real User Monitoring

NEW

Capture actual customer journeys and frontend performance in real time.

Synthetic Monitoring

NEW

Emulate user transactions and SaaS workflows to catch problems early.

Endpoint Monitoring

NEW

Diagnose remote workforce digital experience across devices and networks.

Digital Experience Monitoring

Digital Experience Monitoring

See every dependency, regardless of ownership or location.

Website Monitoring

Protect revenue journeys with proactive synthetic checks and uptime tracking.

CDN Monitoring

NEW

Audit edge performance and latency variance across your CDN providers.

API Monitoring

NEW

Test endpoints and third-party API reliability for critical app integrations.

Application Performance Monitoring

Connect code execution and traces directly to infrastructure health.

DNS Monitoring

NEW

Speed up time to innocence by tracking global nameserver resolution times.

DevOps Lifecycle Monitoring

NEW

Protect release velocity by validating dependencies during deployments.

BGP Monitoring

NEW

Trace global routing changes and path leaks to secure internet reachability.

Logs

Log Management Overview

Centralize and correlate log data to resolve incidents before they escalate.

Log Analytics & Intelligence

Correlate contextual log data with metrics to speed up root-cause analysis.

By Business Outcome

Autonomous IT

Predictive, autonomous IT built for resilience.

Automation

Eliminate repetitive operational toil with safe, policy-governed remediation workflows.

Modernization and Transformation

Accelerate complex technology transitions while protecting core enterprise resilience.

Cloud Migration

Maintain workload performance throughout migration.

Tool Consolidation

Reduce licensing costs and data silos by replacing fragmented monitoring tools.

Cost Optimization

Lower your total cost-to-serve by finding cloud waste and underused resources.

Operational Efficiency

Maximize team capacity by reducing alert storms and shift-handoff friction.

Reduce MTTR

Shorten war-room by surfacing topology-aware probable cause in mins.

Network Reachability

NEW

Independently audit external BGP, ISP, and SaaS provider connectivity boundaries.

Edge Deployment Optimization

NEW

Monitor SLOs, compare providers, and validate cloud and edge delivery.

Web Performance Optimization

NEW

Maximize digital checkout conversions by tracking global frontend latency metrics.

Application Resilience

NEW

Safeguard business services against transaction failures and costly downtime.

Workforce Productivity

NEW

Troubleshoot remote hardware and network issues to protect productivity.

By Role

CIO

Maximize enterprise resilience and align AI investments to measurable business ROI.

AIOps

Compress cross-domain event noise into explainable, automated ops leverage.

DevOps

Speed up releases by protecting engineering roadmaps from toil.

ITOps

Standardize incident response to reduce alert fatigue and after-hours work.

CloudOps

Unify multi-cloud visibility to optimize costs and track hybrid blast radius.

By Industry

Healthcare

Protect continuity of care and EHR availability across clinical workflows.

Public Sector

Ensure mission continuity and audit readiness for citizen-facing services.

MSP

Protect service margins and scale ops using multi-tenant, AI-assisted triage.

Retail & E-commerce

Safeguard peak retail campaigns, POS uptime, and digital customer journeys.

Technology

Protect customer trust and engineering velocity with SLA-driven visibility.

Hospitality

Deliver frictionless guest experiences and keep booking engines online.

Education

Maintain always-on student portals, learning platforms, and campus networks.

Manufacturing

Prevent production downtime by unifying IT, OT-adjacent, and edge systems.

Financial Services

Secure transaction trust and meet strict operational resilience compliance requirements.

Resources

Blog

Insights and advice from the experts on all things observability and AI.

Case Studies

See what real users have to say about the LogicMonitor platform.

Webinars

Live and on-demand learning, all in one place.

IT Guides

Learn from expert guides on the topics that matter most to IT teams.

How We Compare

See how our platform stacks up against other solutions.

Upcoming Events

Viee of a bridge over a river leading to Cologne cathedral rising against the skyline and a blue sky

CONFERENCE

Digital X Cologne

September 8, 2026

CONFERENCE

SWORD Day

September 17, 2026

View all events

Join us at innovation-focused conferences, tech talks, webinars, and other events.

Platform Help

Support Docs

Access product docs, release notes, and support resources.

LM Community

Join the community to learn from peers, ask questions, and connect with experts.

Customer Education

Learn more about our platform through resources and live trainings.

LOGICMONITOR BLOG

Abstracting Credentials from Python Scripts

Python has rapidly grown into one of the most popular languages for automation. That’s why LogicMonitor supports Python when it comes to managing your LM portal and expanding your monitoring coverage with scripts. During your scripting adventures, you may find yourself wanting to take your work to the next level. LogicMonitor Solutions Engineer, Jeoffri Davis, highlights best practices in our latest blog post. Check it out!

8–12 minutes
June 14, 2019

IN THIS ARTICLE

NEWSLETTER

Subscribe to our newsletter

Get the latest blogs, whitepapers, eGuides, and more straight into your inbox.

SHARE

Python has rapidly grown into one of the most popular languages for automation. That’s why LogicMonitor supports Python when it comes to managing your LM portal and expanding your monitoring coverage with scripts. During your scripting adventures, you may find yourself wanting to take your work to the next level. One widely-applicable improvement is credential abstraction.

Defining Abstraction and Its Benefits

Simply put, abstraction in scripting hides a code implementation. Abstraction can have a number of benefits including:

  • Points of improved code legibility or reduced code execution complexity
  • Improved code reusability
  • Preparing interfaces

This is commonly seen when we talk about using modules or libraries in scripting. Someone else has done the heavy lifting, packaging their detailed work into a library. We as end users simply use the abstracted version of their work so that we can focus on higher level implementations. Part of why Python’s barrier of entry is so low is because of this common, architectural abstraction.

Use Cases for Abstracting Credentials

Let’s use the LogicMonitor REST API as an example. API credentials have a one-to-one relationship with their applicable portals: one set of credentials will work for only one LM portal. You might consider abstracting credentials if you:

  1. Wrote one script that I want to use across multiple LM portals without needing to save a new copy of the script for each portal.
  2. Want your script to work but only when executed in a specific environment as a means of helping control where the script is hosted.
  3. Backup your scripts to a version control system like a Git repository and do not want to save credentials directly in the backup copies.

Common Abstraction Options

Credentials and other potentially sensitive data are commonly abstracted out of scripts by retrieving their values from:

  1. The command line
  2. Environment variables
  3. Files

We will cover options 1 and 2. Note that each scripting and programming language will have a different syntax for these options. In Python, you would use argparse and os.getenv.

Many internet suggestions recommend Python’s os.environ method for retrieving environment variables; however, the os.environ method will throw an exception and prematurely end your script’s execution if any environment variable you try to access does not actually exist. With os.getenv, you can define a backup value so that if the environment variable doesn’t exist, a default value will automatically substitute. It’s a win-win situation in my opinion.

Example Python Script for Abstracting Credentials

# Author: Jeoffri Davis
# Purpose:
#       - Example of abstracting LM REST API credentials
# Tested With:
#       - Python 3.7
#       - MacOS Mojave
# Requires:
#       - Python module(s): argparse
#       - LogicMonitor API credentials (access id and access key)
# Inputs:
#       - LogicMonitor API credentials (access id and access key)
# Outputs:
#       - Echoes credentials to stdout
import argparse
import os
def parse_command_line_arguments():
   """
   Parse arguments from command line and return results in an object.
   Abstracting credentials out of the script can improve flexibility in
   changing credentials and security.
   Using argparse:
       https://docs.python.org/3/howto/argparse.html
   Getting OS env vars while also specifying a default value:
       https://docs.python.org/3.7/library/os.html#os.getenv
   """
   # Define hash table with argument help strings
   arg_help = {
       'description': 'This script demonstrates a way \
           to avoid hard coding credentials. Abstract \
           out credentials by retrieving them from the \
           command line, or, fall back to OS env vars. \
           Consider script execution in test and production. \
           In test, you may want the default output \
           verbosity, which prints output to standard out. \
           In production, you may want faster script \
           execution by using the -q or --quiet option, \
           which skips printing output to standard out.',
       'access_key': 'LogicMonitor REST API Access Key, \
           available from LM portal>Settings>Users & Roles>API Tokens',
       'access_id': 'LogicMonitor REST API Access ID, \
           available from LM portal>Settings>Users & Roles>API Tokens',
       'company': 'Company name for LogicMonitor portal',
       'quiet': 'Hide script output'
   }
   # Use argparse to read arguments
   parser = argparse.ArgumentParser(description=arg_help['description'])
   parser.add_argument(
       "-a", "--access-key",
       default=os.getenv('LM_ACCESS_KEY', 'Default key'),
       help=arg_help['access_key']
   )
   parser.add_argument(
       "-b", "--access-id",
       default=os.getenv('LM_ACCESS_ID', 'Default id'),
       help=arg_help['access_id']
   )
   parser.add_argument(
       "-c", "--company-name",
       default=os.getenv('LM_COMPANY_NAME', 'Default company'),
       help=arg_help['company']
   )
   parser.add_argument(
       "-q", "--quiet",
       action='store_true',
       help=arg_help['quiet']
   )
   args = parser.parse_args()
   return args
def main():
   # Abstract out credentials by retrieving them from
   # the command line, or, fall back to OS env vars
   credentials = parse_command_line_arguments()
   # Consider script execution in test and production.
   # In test, you may want the default output verbosity,
   # which prints output to standard out. In production,
   # you may want faster script execution by using the
   # -q or --quiet option, which skips printing output
   # to standard out.
   if not credentials.quiet:
       print("Access Key: " + credentials.access_key)
       print("Access ID: " + credentials.access_id)
       print("Company: " + credentials.company_name)
       print("Quiet: " + str(credentials.quiet))
if __name__ == '__main__':
   main()

Benefits of Command Line Parsers such as Python Argparse

Modern command line parsers generally offer a couple of benefits:

  1. Obtaining values either from the command line, or, predefined defaults
  2. Automatically generating script usage

Our example uses Python’s argarse in order to define values for specific information: LogicMonitor credentials–access key, access id, and company–as well as a verbosity option called “quiet”. These are variables whose values aren’t hard coded directly in the script. Rather, the values could come from interfacing with another source of information because the values are passed into, or “abstracted out of”, the script. Using a second script as wrapper, we can apply this one, original copy of the Python script to multiple LM portals. We could backup copies of the script once or regularly without needing to remove credentials first. If we didn’t supply any explicit credentials through the command line, we could leverage environment variables defined at the host’s operating system level or lower such as a terminal session or container. This means the same script would fail if we moved to a different environment and attempted to execute it without having the environment variables in place.

Scripts that use their language’s command line parser can normally be called with a “-h”, “–help”, or equivalent option in order to see the automatically generated script usage. Python argparse, Groovy CliBuilder, and PowerShell comment based help are examples of where this is possible.

Examples of Python Script Execution and Output

Note that in the examples below “ATX-JDAVIS:python_abstract_credentials jdavis$” is a command line prompt and “abstracted_credentials.py” is the file containing our example code.

Obtaining Python Script Usage Help

Here is an example of executing our script with Python argparse’s “–help” option in order to see the script usage automatically generated by argparse. 

ATX-JDAVIS:python_abstract_credentials jdavis$ python3 ./abstracted_credentials.py --help
usage: abstracted_credentials.py [-h] [-a ACCESS_KEY] [-b ACCESS_ID]                                 [-c COMPANY_NAME] [-q]
This script demonstrates a way to avoid hard coding credentials. Abstract out credentials by retrieving them from the command line, or, fall back to OS env vars. Consider script execution in test and production. In test, you may want the default output verbosity, which prints output to standard out. In production, you may want faster script execution by using the -q or --quiet option, which skips printing output to standard out.
optional arguments:
  -h, --help            show this help message and exit
  -a ACCESS_KEY, --access-key ACCESS_KEY
                        LogicMonitor REST API Access Key, available from LM portal>Settings>Users & Roles>API Tokens
  -b ACCESS_ID, --access-id ACCESS_ID
                        LogicMonitor REST API Access ID, available from LM portal>Settings>Users & Roles>API Tokens
  -c COMPANY_NAME, --company-name COMPANY_NAME
                        Company name for LogicMonitor portal
  -q, --quiet           Hide script output
ATX-JDAVIS:python_abstract_credentials jdavis$

Execution with Command Line Arguments

In this example, we define values for our command line arguments rather than relying on defaults. We could call this script multiple times, sequentially or in parallel, while also supplying different inputs. The script itself; however, would remain unchanged as all values are abstracted out.

ATX-JDAVIS:python_abstract_credentials jdavis$ python3 ./abstracted_credentials.py -a "I used the short-hand command line option of 'a' to supply my own access key" --access-id "My Custom Access ID" -c "LogicMonitor"
Access Key: I used the short-hand command line option of 'a' to supply my own access key
Access ID: My Custom Access ID
Company: LogicMonitor
Quiet: False
ATX-JDAVIS:python_abstract_credentials jdavis$ 

Execution with Default Command Line Argument Values

Here is an interesting example of executing our script while retrieving a mix of values from environment variables and predefined defaults.

 
ATX-JDAVIS:python_abstract_credentials jdavis$ python3 ./abstracted_credentials.py
Access Key: %c3)j}]5_5mZ6gF)QkN$6-zV4L+[9Qd32V!{%n(}
Access ID: k9NzWaIQFImBu36aSWP8
Company: Default company
Quiet: False
ATX-JDAVIS:python_abstract_credentials jdavis$

We did not supply command line arguments and the order in which our script checks for credentials is command line, environment variables, and then defaults. My developer environment had environment variables defined for access key and id, but not for company or quiet. The script, therefore, automatically used the default values for company and quiet.

Execution with Quiet Option

An unexciting but necessary example of suppressing script output. Note that the quiet option operates like a switch. If it’s present then the assumed value is a Boolean “True”; otherwise, the assumed value is a Boolean “False”.

ATX-JDAVIS:python_abstract_credentials jdavis$ python3 ./abstracted_credentials.py --quiet
ATX-JDAVIS:python_abstract_credentials jdavis$

You typically want this quiet option in production environments where you won’t watch the script execution in real time. Writing the output to a log, which isn’t covered in this article, is a good companion to suppressing prints to standard out.

Implementation Risks

No implementation is perfect in all ways. Often we make tradeoffs, striving for key benefits while either mitigating or accepting unfavorable consequences. Some of the risks of abstracting credentials as we demonstrated include the following.

Code Legibility and Maintainability

Ironically, code complexity increases specifically where command line parsing is implemented. In our example, one would need to understand Python argparse in order to maintain that portion of the script. This is an unavoidable tradeoff in order to achieve increased script flexibility.

False Sense of Significantly Heightened Security

Reduced credential visibility is better than none. On the other hand, it can lead some people to believe their script has immediately become exponentially more secure. If security were your primary driver, then abstracting credentials out of scripts would be a critical first step; however, you would not stop there because any process reporting tool will be able to capture and report any command line options passed to a script.

For example, in macOS and Linux environments you could insert a wait time into our example script, execute the script in one terminal, and then execute the ps -ef command in another terminal in order to capture the running Python process. The ps command may return an entire screen worth of results. You can filter down the response by piping the results into grep, which will let you search for particular strings. You can see below that our credentials were abstracted but not entirely hidden because we’re still able to find our example script executing with an access key of “Can you find this?”.

ATX-JDAVIS:~ jdavis$ ps -ef | grep 'Can you find this?'
  501 61873 61739   0 10:44PM ttys000    0:00.04 /Library/Frameworks/Python.framework/Versions/3.7/Resources/Python.app/Contents/MacOS/Python ./abstracted_credentials.py --access-key Can you find this?
  501 61979 61575   0 10:45PM ttys005    0:00.00 grep Can you find this?
ATX-JDAVIS:~ jdavis$

For increased security, research obfuscation and encryption. While noteworthy topics, they are not the focus of this article.

Conclusion

This article illustrated Python argparse, one of many examples of how one can abstract credentials from scripts. Abstraction allows scripts to become flexible and scale in a number of ways. We reviewed an example that removed the one-to-one relationship between a Python script that leverages the LM REST API, and the number of portals to which wanted to apply the script. We touched on increasing script complexity in one place in order to improve the overall user experience. Finally, we clarified that abstraction does not equate to immediate security improvements.

© LogicMonitor 2026 | All rights reserved. | All trademarks, trade names, service marks, and logos referenced herein belong to their respective companies.

Related Blogs

The $1 Million Lesson: Building a Culture of Quality Through SLAs
Blog Internet Performance Monitoring

The $1 Million Lesson: Building a Culture of Quality Through SLAs

A single $1M SLA penalty taught one lasting rule: measure service the way your customers feel it. Here’s how to build SLAs that hold up and protect revenue.
September 1, 2026
Learn more
Critical Requirements for Modern API Monitoring
Blog Internet Performance Monitoring

Critical Requirements for Modern API Monitoring

Discover why server-side API monitoring falls short and how Internet Performance Monitoring delivers the end-to-end visibility that modern systems demand.
September 1, 2026
Learn more
Zendesk Outage: A Case for Proactive Monitoring and Faster Incident Response
Blog Internet Performance Monitoring

Zendesk Outage: A Case for Proactive Monitoring and Faster Incident Response

See how Internet Performance Monitoring caught the Zendesk outage a full 21 minutes early and what it teaches teams about proactive monitoring and faster incident response.
September 1, 2026
Learn more

Product

Platform

Infrastructure

Cloud & Multi-Cloud

Log Management

Edwin AI

Enterprise

Demo

Pricing

WebPageTest Pricing

RUM Monitoring

IPM Monitoring

Synthetic Monitoring

How We Compare

Datadog

Dynatrace

Virtana

Solarwinds

PRTG

ManageEngine

ScienceLogic

SiteScope

BigPanda

About

Careers

Our Partners

Leadership

Newsroom

Security

AI Governance

Sustainability

Legal

Documentation

Docs Hub

Release Notes

Security

Support Center

Resources

Autonomous IT in 2026

Resource Library

LM Academy

Blog

Case Studies

Customer Education

Connect

Contact & Locations

Submit a Ticket

Events

LM Community

Careers


Product

Platform

Infrastructure

Cloud & Multi-Cloud

Log Management

Edwin AI

Enterprise

Demo

Pricing

WebPageTest Pricing

RUM Monitoring

IPM Monitoring

Synthetic Monitoring


How We Compare

Datadog

Dynatrace

Virtana

Zenoss

Solarwinds

PRTG

ManageEngine

ScienceLogic

SiteScope

BigPanda


About

Careers

Our Partners

Leadership

Newsroom

Security

AI Governance

Sustainability

Legal


Documentation

Docs Hub

Release Notes

Security

Support Center


Resources

Autonomous IT in 2026

Resource Library

LM Academy

Blog

Case Studies

Customer Education


Connect

Contact & Locations

Submit a Ticket

Events

LM Community

Careers


Privacy Policy

Terms of Use

Preference Center

Do Not Sell My Information

© 2026 LogicMonitor