webdevops/azure-janitor

By webdevops

Updated 19 days ago

Image
Integration & Delivery
Monitoring & Observability
Security

10K+

Azure Janitor

licenseDockerDocker Build Status

Janitor for Azure ResourceGroups and Resources based on ttl tag and Deployments based on TTL and limit.

Configuration

Normally no configuration is needed but can be customized using environment variables.

Environment variableDefaultValueDescription
AZURE_SUBSCRIPTION_IDemptyAzure Subscription IDs (empty for auto lookup)
DRYRUNemptyDryRun (non deleting mode)
SERVER_BIND:8080IP/Port binding for metrics and healthcheck
JANITOR_INTERVAL1hHow often Azure Janitor should cleanup the subscriptions (time.Duration)
JANITOR_TAGttlResource tag name for ttl value (non deleting mode)
JANITOR_RESOURCE_APIVERSION2019-03-01API version for Azure Resource deletion
JANITOR_DISABLE_RESOURCEGROUPSfalseEnable/Disable Azure ResourceGroup clearing
JANITOR_DISABLE_RESOURCESfalseEnable/Disable Azure Resource clearing
JANITOR_DISABLE_DEPLOYMENTSfalseEnable/Disable Azure Deployment clearing
JANITOR_FILTER_RESOURCESemptyAdditional Azure REST API $filter for Azure ResourceGroups
JANITOR_FILTER_RESOURCEGROUPSemptyAdditional Azure REST API $filter for Azure Resources
JANITOR_DEPLOYMENT_TTL8760hTTL (Expiry) for Azure ResourceGroup Deployments
JANITOR_DEPLOYMENT_LIMIT700Limit (count) of Azure ResourceGroup Deployments per ResourceGroup (Azure limit: 800)

for Azure API authentication (using ENV vars) see https://github.com/Azure/azure-sdk-for-go#authentication

Azure tag

By default the Azure Janitor is using ttl as tag to trigger a cleanup if the resource is expired.

Supported absolute timestamps

  • 2006-01-02 15:04:05 +07:00
  • 2006-01-02 15:04:05 MST
  • 2006-01-02 15:04:05
  • 02 Jan 06 15:04 MST (RFC822)
  • 02 Jan 06 15:04 -0700 (RFC822Z)
  • Monday, 02-Jan-06 15:04:05 MST (RFC850)
  • Mon, 02 Jan 2006 15:04:05 MST (RFC1123)
  • Mon, 02 Jan 2006 15:04:05 -0700 (RFC1123Z)
  • 2006-01-02T15:04:05Z07:00 (RFC3339)
  • 2006-01-02T15:04:05.999999999Z07:00 (RFC3339Nano)

Supported relative timestamps (tag will be updated with absolute timestamp as soon it's found)

Metrics

MetricTypeDescription
azurejanitor_durationGaugeDuration of cleanup run in seconds
azurejanitor_resources_ttlGaugeList of Azure resources and resourcegroups with labels and expiry timestamp as value
azurejanitor_resources_deletedCounterNumber of deleted resources (by resource type)
azurejanitor_errorsCounterNumber of failed deleted resources (by resource type)

Docker Pull Command

docker pull webdevops/azure-janitor