|
| 1 | +.. _apm-create-data-links-terraform-file: |
| 2 | + |
| 3 | +***************************************************************************** |
| 4 | +Create global data links to Splunk AppDynamics tiers with a Terraform file |
| 5 | +***************************************************************************** |
| 6 | + |
| 7 | +.. meta:: |
| 8 | + :description: Learn how to use a Terraform configuration file to create global data links to Splunk AppDynamics tiers. |
| 9 | + |
| 10 | +.. note:: |
| 11 | + You can only create a global data link from a Splunk APM inferred service to a Splunk AppDynamics tier if the tier is monitored by a Splunk AppDynamics SaaS environment. |
| 12 | + |
| 13 | + This method can only be used to create global data links for inferred services that do not have existing global data links. If your inferred service already has an existing global data link, :ref:`use the UI <apm-create-gdl-to-appd>` to create additional global data links. |
| 14 | + |
| 15 | +When a transaction goes through a service monitored by Splunk APM as well as a tier monitored by Splunk AppDynamics, the service monitored by Splunk APM is considered an inferred service. |
| 16 | + |
| 17 | +Create a global data link to link a Splunk APM inferred service to a Splunk AppDynamics tier. When you view the inferred service in Splunk APM, you can select the data link to navigate to the tier in the Splunk AppDynamics user interface. |
| 18 | + |
| 19 | +You can programmatically create global data links to Splunk AppDynamics tiers with a Terraform configuration file. |
| 20 | + |
| 21 | +Prerequisites |
| 22 | +================= |
| 23 | + |
| 24 | +To create a global data link to a Splunk AppDynamics tier using the Node.js script, you need: |
| 25 | + |
| 26 | +* A Splunk Observability Cloud account with the admin role. |
| 27 | +* The latest version of Terraform. |
| 28 | + |
| 29 | +Create data links with a Terraform configuration file |
| 30 | +======================================================== |
| 31 | + |
| 32 | +To create data links with a Terraform configuration file: |
| 33 | + |
| 34 | +#. In the Terraform directory, create a Terraform configuration file named <file-name>.tf with the following contents: |
| 35 | + .. code-block:: terraform |
| 36 | +
|
| 37 | + # Specify the Terraform provider and version |
| 38 | + terraform { |
| 39 | + required_providers { |
| 40 | + signalfx = { |
| 41 | + source = "splunk-terraform/signalfx" |
| 42 | + version = "~> <current-splunk-terraform-provider-version>" |
| 43 | + } |
| 44 | + } |
| 45 | + } |
| 46 | +
|
| 47 | + # The following variable blocks can also be located in a variables.tf file in the same directory |
| 48 | + variable "signalfx_auth_token" { |
| 49 | + description = "The user API access authentication token for your org" |
| 50 | + type = string |
| 51 | + default = "" |
| 52 | + } |
| 53 | + variable "signalfx_api_url" { |
| 54 | + description = "The API URL of your org" |
| 55 | + type = string |
| 56 | + default = "" |
| 57 | + } |
| 58 | +
|
| 59 | + # Configure the Splunk Observability Cloud provider |
| 60 | + provider "signalfx" { |
| 61 | + auth_token = "${var.signalfx_auth_token}" |
| 62 | + api_url = "${var.signalfx_api_url}" |
| 63 | + } |
| 64 | +
|
| 65 | + - For ``version``, enter the current Splunk Observability Cloud Terraform provider version. To check the latest version, see :new-page:`Releases <https://github.com/splunk-terraform/terraform-provider-signalfx/releases>`. This value must be 9.6.0 or higher. |
| 66 | + - (Optional) Add arguments as needed for your configuration. For more information on the supported arguments, see :new-page:`Splunk Observability Cloud provider <https://registry.terraform.io/providers/splunk-terraform/signalfx/latest/docs#arguments>` in the Terraform documentation. |
| 67 | + |
| 68 | +#. Add the :new-page:`signalfx_data_link <https://registry.terraform.io/providers/splunk-terraform/signalfx/latest/docs/resources/data_link>` resource to the Terraform file: |
| 69 | + .. code-block:: none |
| 70 | +
|
| 71 | + # A link to a Splunk AppDynamics service |
| 72 | + resource "signalfx_data_link" "<data-link-id>" { |
| 73 | + property_name = "sf_service" |
| 74 | + property_value = "<splunk-inferred-service-name>" |
| 75 | +
|
| 76 | + target_appd_url { |
| 77 | + name = "<data-link-ui-label>" |
| 78 | + url = "<https://www.example.saas.appdynamics.com/#/application=1234&component=5678>" |
| 79 | + } |
| 80 | + } |
| 81 | +
|
| 82 | + - For <data-link-id>, enter an identifier for the data link. This value is only visible in the Terraform file and must be unique for each data link. For example, you can use my_data_link_appd_1 or my_data_link_appd_2. |
| 83 | + - For ``property_name``, use ``sf_service``. |
| 84 | + - For ``property_value``, enter the Splunk APM inferred service name. |
| 85 | + - For ``name``, enter a label for the data link. This label appears in the Splunk Observability Cloud user interface. |
| 86 | + - For ``URL``, enter the Splunk AppDynamics tier URL. |
| 87 | + To obtain the tier URL, navigate to the tier in the Splunk AppDynamics UI and copy the URL from the browser. Ensure that you capture the entire URL and that it contains the controller URL, application ID, and application component. |
| 88 | + |
| 89 | +#. Repeat the previous step for each data link to a Splunk AppDynamics tier you want to create. The following example displays a Terraform configuration file with multiple data links to Splunk AppDynamics tiers: |
| 90 | + .. code-block:: terraform |
| 91 | +
|
| 92 | + # Specify the Terraform provider and version |
| 93 | + terraform { |
| 94 | + required_providers { |
| 95 | + signalfx = { |
| 96 | + source = "splunk-terraform/signalfx" |
| 97 | + version = "~> 9.6.0" |
| 98 | + } |
| 99 | + } |
| 100 | + } |
| 101 | +
|
| 102 | + # The following variable blocks can also be located in the variables.tf file in the same directory |
| 103 | + variable "signalfx_auth_token" { |
| 104 | + description = "The user API access auth token for your org" |
| 105 | + type = string |
| 106 | + default = "" |
| 107 | + } |
| 108 | + variable "signalfx_api_url" { |
| 109 | + description = "The API URL of your org" |
| 110 | + type = string |
| 111 | + default = "" |
| 112 | + } |
| 113 | +
|
| 114 | + # Configure the Splunk Observability Cloud provider |
| 115 | + provider "signalfx" { |
| 116 | + auth_token = "${var.signalfx_auth_token}" |
| 117 | + api_url = "${var.signalfx_api_url}" |
| 118 | + } |
| 119 | + # If your organization uses a custom URL, replace api_url with: |
| 120 | + # custom_app_url = "https://myorg.signalfx.com" |
| 121 | +
|
| 122 | + # A link to a Splunk AppDynamics service |
| 123 | + resource "signalfx_data_link" "my_data_link_appd_1" { |
| 124 | + property_name = "sf_service" |
| 125 | + property_value = "placed_orders" |
| 126 | +
|
| 127 | + target_appd_url { |
| 128 | + name = "appd_url_placed_orders" |
| 129 | + url = "https://www.example.saas.appdynamics.com/#/application=1234&component=5678" |
| 130 | + } |
| 131 | + } |
| 132 | +
|
| 133 | + # A link to a Splunk AppDynamics service |
| 134 | + resource "signalfx_data_link" "my_data_link_appd_2" { |
| 135 | + property_name = "sf_service" |
| 136 | + property_value = "returned_orders" |
| 137 | +
|
| 138 | + target_appd_url { |
| 139 | + name = "appd_url_returned_orders" |
| 140 | + url = "https://www.example.saas.appdynamics.com/#/application=4321&component=8765" |
| 141 | + } |
| 142 | + } |
| 143 | +
|
| 144 | +#. In the working directory with your Terraform configuration file, run the following command to initialize the directory: |
| 145 | + .. code-block:: none |
| 146 | +
|
| 147 | + terraform init |
| 148 | +
|
| 149 | +#. To set your signalfx_auth_token and signalfx_api_url variables and generate a preview of the changes that Terraform will make, run: |
| 150 | + .. code-block:: none |
| 151 | +
|
| 152 | + terraform plan -var="signalfx_auth_token=<api-access-token>" -var="signalfx_api_url=https://api.<realm>.signalfx.com" -out=<plan-file-name> |
| 153 | + |
| 154 | + - For <api-access-token>, enter your Splunk Observability Cloud API access token. To obtain it, navigate to Splunk Observability and select your profile in the header. Select :guilabel:`My Profile`, then :guilabel:`Show User API Access Token`, and copy the API access token. |
| 155 | + - For <realm>, enter your Splunk Observability Cloud realm. To obtain your realm, navigate to Splunk Observability Cloud and select your profile in the header. Select :guilabel:`My Profile`, then :guilabel:`Organizations`, and copy the :guilabel:`Realm`. |
| 156 | + - For <plan-file-name>, enter your desired name for the plan file that Terraform will create for the changes. |
| 157 | + |
| 158 | +#. Use the output to review the changes. To run the changes and create a terraform.tf.state file that lists the resources that Terraform created: |
| 159 | + .. code-block:: none |
| 160 | +
|
| 161 | + terraform apply "<plan-file-name>" |
| 162 | +
|
| 163 | +#. To verify that the global data links were successfully created, use one of the following methods: |
| 164 | + - View the output of the command. Sample output for a successful execution: ``Apply complete! Resources: 3 added, 0 changed, 0 destroyed``. |
| 165 | + - View the terraform.tfstate file in the Terraform directory, which contains the list of created resources. |
| 166 | + - View the global data links in the UI. In the Splunk Observability Cloud main menu, select :guilabel:`Settings` then :guilabel:`Global Data Link`. Search the page for the data link name that you specified in the Terraform file. |
| 167 | + |
| 168 | +Next steps |
| 169 | +============= |
| 170 | + |
| 171 | +To access global data links in the user interface, see :ref:`apm-access-gdl-service`. |
| 172 | + |
| 173 | +To delete all global data links using Terraform, see :ref:`apm-delete-data-links-terraform`. |
| 174 | + |
0 commit comments