Context Variables Reference

Reference for context variables that you can use in your deployment config file.

Variables included with CD-as-a-Service

Armory provides some metrics by default on all canary analysis requests. These variables are all prefixed with armory and are surrounded by {{}}. For example, to use applicationName variable that Armory supplies, you use the following snippet in the query template: {{armory.applicationName}}.

CD-as-a-Service includes the following variables:

VariableAnnotationEnvironment variableNotes
accountName--The name of the account (or agentIdentifier) used to execute the deployment
applicationNamedeploy.armory.io/applicationARMORY_APPLICATION_NAMEAdded as annotation resources and as environment variables on pods.1
deploymentIddeploy.armory.io/deployment-idARMORY_DEPLOYMENT_IDAdded as annotation resources and as environment variables on pods.1
endTimeEpochMillis--Exact end time of the current query interval in epoch milliseconds format
endTimeEpochSeconds--Exact end time of the current query interval in epoch seconds format
endTimeIso8601--Exact end time of the current query interval in ISO 8601 format
environmentNamedeploy.armory.io/environmentARMORY_ENVIRONMENT_NAMEAdded as annotation resources and as environment variables on pods.1
intervalMillis--Length of the current query interval in milliseconds
intervalSeconds--Length of the current query interval in seconds
namespace--The namespace resources are being deployed to
preview.<service name>--URL to the Service resource exposed via exposeServices step.2
promQlStepInterval--Used to aggregate PromQL functions to a single value
replicaSetNamedeploy.armory.io/replica-set-nameARMORY_REPLICA_SET_NAMEAdded as annotation resources and as environment variables on pods.1
startTimeEpochMillis--Exact start time of the current query interval in epoch milliseconds format
startTimeEpochSeconds--Exact start time of the current query interval in epoch seconds format
startTimeIso8601--Exact start time of the current query interval in ISO 8601 format

1: If you are using a metrics implementation like Micrometer, make sure to configure it to report these metrics to your metrics provider.

2: Service preview links are scoped to the strategy and afterDeployment constraints section. Do consider adjusting preview link’s TTL property, otherwise you may end up serving links which have already expired.

If your deployment strategy contains an exposeServices step, all exposed service preview links are available as part of the armory.preview sub-context. For example, if you create service preview for service my-http-service you could access it using armory.preview.my-http-service.

Custom variables

You can also define custom variables. These are added to the strategies.<strategyName>.canary.steps.analysis.context section of your deployment file:

strategies:
  ...
    canary:
      steps:
        ...
        - analysis:
            ...
            context:
              - <variableName>: <variableValue>

You need to define the variables in each analysis step that uses a query referencing them.

In query templates, you reference them with the following format: {{context.<variableName>}}. For example, if you created a variable called owner, you reference it in the query template with {{context.owner}}.


Last modified October 10, 2023: (db84da5)