Categorygithub.com/webdevops/azure-auditor
modulepackage
0.0.0-20240822165557-0dcb6dd2cd0c
Repository: https://github.com/webdevops/azure-auditor.git
Documentation: pkg.go.dev

# README

Azure Auditor

license DockerHub Quay.io Artifact Hub

Auditor for Azure resources and settings with Prometheus metrics (violations) for alerting

Audit reports:

  • ResourceGroups
  • RoleAssignments
  • ResourceProviders
  • ResourceProviderFeatures
  • Keyvault AccessPolicies
  • ResourceGraph queries

Usage

Usage:
  azure-auditor [OPTIONS]

Application Options:
      --log.debug                                   debug mode [$LOG_DEBUG]
      --log.devel                                   development mode [$LOG_DEVEL]
      --log.json                                    Switch log output to json format [$LOG_JSON]
      --azure.environment=                          Azure environment name (default: AZUREPUBLICCLOUD) [$AZURE_ENVIRONMENT]
      --azure.tenant=                               Azure tenant id [$AZURE_TENANT_ID]
      --azure.subscription=                         Azure subscription ID [$AZURE_SUBSCRIPTION_ID]
      --azure.tag.inherit=                          Inherit tags [$AZURE_TAG_INHERIT]
      --report.title=                               Report title [$REPORT_TITLE]
      --report.pagination.size=[5|10|25|50|100|250] Report pagination size (default: 50) [$REPORT_PAGINATION_SIZE]
      --cron.keytvaultaccesspolicies=               Cronjob for KeyVault AccessPolicies report (default: 0 * * * *)
                                                    [$CRON_KEYTVAULTACCESSPOLICIES]
      --cron.resourcegroups=                        Cronjob for ResourceGroups report (default: */30 * * * *) [$CRON_RESOURCEGROUPS]
      --cron.resourceproviders=                     Cronjob for ResourceProviders report (default: 0 * * * *) [$CRON_RESOURCEPROVIDERS]
      --cron.roleassignments=                       Cronjob for RoleAssignments report (default: */5 * * * *) [$CRON_ROLEASSIGNMENTS]
      --cron.resourcegraph=                         Cronjob for ResourceGraph report (default: 15 * * * *) [$CRON_RESOURCEGRAPH]
      --cron.loganalytics=                          Cronjob for LogAnalytics report (default: 30 * * * *) [$CRON_LOGANALYTICS]
      --loganalytics.waitduration=                  Wait duration between LogAnalytics queries (default: 5s) [$LOGANALYTICS_WAITDURATION]
      --config=                                     Config file path [$CONFIG]
      --dry-run                                     Dry Run (report only) [$DRYRUN]
      --server.bind=                                Server address (default: :8080) [$SERVER_BIND]
      --server.timeout.read=                        Server read timeout (default: 5s) [$SERVER_TIMEOUT_READ]
      --server.timeout.write=                       Server write timeout (default: 10s) [$SERVER_TIMEOUT_WRITE]
      --server.path.report=                         Server path for report [$SERVER_PATH_REPORT]

Help Options:
  -h, --help                                        Show this help message

crons can be disabled by setting them to empty string or false

for Azure API authentication (using ENV vars) see https://docs.microsoft.com/en-us/azure/developer/go/azure-sdk-authentication

For AzureCLI authentication set AZURE_AUTH=az

Configuration file

see (example.yaml)[/example.yaml] as for example audit rules

Metrics

MetricDescription
azurerm_audit_violation_roleassignmentRoleAssingment violations
azurerm_audit_violation_resourcegroupResourceGroup violations
azurerm_audit_violation_resourceproviderResourceProvider violations
azurerm_audit_violation_resourceproviderfeatureResourceProviderFeature violations
azurerm_audit_violation_keyvaultaccesspolicyKeyvault AccessPolicy violations
azurerm_audit_violation_resourcegraph_XXXResourceGraph violations

AzureTracing metrics

(with 22.2.0 and later)

Azuretracing metrics collects latency and latency from azure-sdk-for-go and creates metrics and is controllable using environment variables (eg. setting buckets, disabling metrics or disable autoreset).

MetricDescription
azurerm_api_ratelimitAzure ratelimit metrics (only on /metrics, resets after query due to limited validity)
azurerm_api_request_*Azure request count and latency as histogram

Settings

Environment variableExampleDescription
METRIC_AZURERM_API_REQUEST_BUCKETS1, 2.5, 5, 10, 30, 60, 90, 120Sets buckets for azurerm_api_request histogram metric
METRIC_AZURERM_API_REQUEST_ENABLEfalseEnables/disables azurerm_api_request_* metric
METRIC_AZURERM_API_REQUEST_LABELSapiEndpoint, method, statusCodeControls labels of azurerm_api_request_* metric
METRIC_AZURERM_API_RATELIMIT_ENABLEfalseEnables/disables azurerm_api_ratelimit metric
METRIC_AZURERM_API_RATELIMIT_AUTORESETfalseEnables/disables azurerm_api_ratelimit autoreset after fetch
azurerm_api_request labelStatusDescription
apiEndpointenabled by defaulthostname of endpoint (max 3 parts)
routingRegionenabled by defaultdetected region for API call, either routing region from Azure Management API or Azure resource location
subscriptionIDenabled by defaultdetected subscriptionID
tenantIDenabled by defaultdetected tenantID (extracted from jwt auth token)
resourceProviderenabled by defaultdetected Azure Management API provider
methodenabled by defaultHTTP method
statusCodeenabled by defaultHTTP status code

Endpoints

MetricDescription
/metricsPrometheus metrics incl. audit violations
/configParsed and processes config file
/reportAudit report ui
/healthzHealthz endpoint

# Packages

No description provided by the author
No description provided by the author

# Constants

No description provided by the author
No description provided by the author

# Variables

No description provided by the author