Skip to content

Manage Agent Tags

Tagging enables you to group agents together by using a meaningful name, typically based on common functionality. For example, you can use tags to identify the location and purpose of each agent: Database servers, Staging, and so forth. Additionally, you can apply to each agent multiple tags in any combination.

By applying multiple tags, you can bind actions to an agent before the agent has been launched, and you can apply actions to applications across different sectors. Once an action is bound to a tag, it is implicitly added to all of the agents that possess that tag.

Example

  • Define a tag in the metadata file named "Integration".
  • Add that tag to relevant agents where you're running your application for integration testing.
  • Set integration tests to execute with the Integration tag, in order to debug an integration test failure.
  • List actions by the Integration tag from the CLI with java -jar lightrunc.jar list-actions tag:Integration.
    The output lists all of your agents that inserted actions for integration testing.

Out-of-the-box, agents have a single Production tag. You can:

To create and add a tag to an agent

  1. From the relevant server where the agent is installed, go to the agent.metadata.json file and open it.

  2. Insert tag names within the tags object (which should be nested in the registration object).

    {
        "registration": {
          "tags": [
            {
              "name": "Tag1"
            },
            {
              "name": "Tag2"
            },
            {
              "name": "Tag3"
            }
          ]
        }
    }
    

    For example, the following JSON applies the tags Production, Main, and East US to the relevant agent.

    {
        "registration": {
          "displayName": "Pilot site"
          "tags": [
            {
              "name": "Production"
            },
            {
              "name": "Main"
            },
            {
              "name": "East US"
            }
          ]
        }
    }
    

    Alternatively, tags can be applied using a command line argument as part of the command you use to run the agent with your application.

    The command line arguments should be inserted after the path of the agent and they should be separated by a comma.

    java -Dlightrun.registration.tags=myTag -agentpath:/path/to/agent/lightrun_agent.so RestOfTheArgumentsHere
    
  3. Save the changes and close the file.

  4. Restart the application.

    Important

    Changes to this file aren't detected until the application is restarted.

To view all tag details from the Management Portal

Log in to your Lightrun account and navigate to Entities->Tags.

The Tags screen loads, appearing similar to the example below.

Manage tags

The details displayed in the Tags screen are as follows:

Column Description
Name The tag name
Actions A list of actions currently attached to this tag.
Agents A list of agents with which this tag has been associated.

To view tags from the CLI

  1. Install the Lightrun CLI tool

  2. Run the command java -jar lightrunc.jar list-tags:

    List agents

Info

See the CLI reference for more information.


Last update: May 18, 2022