Manage Lightrun Java 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 multiple tags to each agent in any combination.
By applying multiple tags, you can bind actions to an agent to an agenet before it is launched and 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.
By default, agents have a single Production tag. You can:
Create and add a tag to an agent¶
-
From the relevant server where the agent is installed, go to the
agent.metadata.json
file and open it. -
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": "<DISPLAY_NAME>", "tags": [ { "name": "Production" }, { "name": "Main" }, { "name": "East US" } ] } }
Alternatively, you can apply tags using a command-line argument when running the agent with your application.
Multiple tags can be specified using commas. For example, you can set them like this:
java -Dlightrun.registration.tags=myTag1,myTag2,myOtherTag
-
Save the changes and close the file.
-
Restart the application.
Important
Changes to this file are not detected until the application is restarted.
View all tag details from the Management Portal¶
Log in to your Lightrun account and navigate to Entities->Tags.
The Tags page loads, appearing similar to the example below.
The details displayed in the Tags page 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. |
View tags from the CLI¶
-
Install the Lightrun CLI tool
-
Run the command
java -jar lightrunc.jar list-tags
:
For more information, see the CLI reference.