Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Deployment of Grafana

Azure Deployment via Teraform

Initialization

Create Client ID Client Secret for Subscription

to create a new environment copy the main.tf and terraform.tfvars from sandbox to a new folder. Select the tenent id and subscription you want to target the deploy to. In this process you will need new client id and secrets for the main.tf.
az account set --subscription=<id> az ad sp create-for-rbac --role="Contributor" --scopes="/subscriptions/<id>"

link environment:

This project can deploy a standalone grafana dashboard hosted within its own resoruce group. To deploy first link the environment main.tf and terraform.tfvars to the root directory. If running on windows make sure to launch pwsh as admin and execute python .\scripts\SymLink.py .\<env>\ where the env is the folder name for the environment in the local directory.

** if the command errors you may be missing some pip packages. Install argparse by running pip install argparse **

Deploy

When deploying terraform (tf) infrastructure there are a few notes to keep in mind. First the workspace you are operating in, second the target environment you are deploying the infrastructure to.

Terraform workspace

  • delacre the current workapace by running terraform workspace show.
  • To list all available workpaces terraform workapce list
  • to change the active workspace terraform workspace select <workspace>

With each worksapace you can store different state files for the resources deployed to each environemt. In the case of sandbox which was already depoyed. running terraform workspace select sandbox and then terraform state list will show these resources as controlled by the state file.

however when changing to the prod workspace terraform workapces select prod the state file is currently empty terraform state list

╭─[lmancuso@LT10-LMANCUSO]
╰─[ master ● ?8 ~2]-ff tf workspace select default
Switched to workspace "default".
╭─[lmancuso@LT10-LMANCUSO]
╰─[ master ● ?8 ~2]-ff tf workspace show
default
╭─[lmancuso@LT10-LMANCUSO]
╰─[ master ● ?8 ~2]-ff tf workspace list
* default
  prod
  sandbox
╭─[lmancuso@LT10-LMANCUSO]
╰─[ master ● ?8 ~2]-ff tf state list
╭─[lmancuso@LT10-LMANCUSO]
╰─[ master ● ?8 ~2]-ff tf workspace select sandbox
Switched to workspace "sandbox".
╭─[lmancuso@LT10-LMANCUSO]
╰─[ master ● ?8 ~2]-ff tf state list
azurerm_container_group.grafana
azurerm_resource_group.resource_group
azurerm_storage_account.container_storage
azurerm_storage_share.container_share
╭─[lmancuso@LT10-LMANCUSO]
╰─[ master ● ?8 ~2]-ff tf workspace select prod   
Switched to workspace "prod".
╭─[lmancuso@LT10-LMANCUSO]
╰─[ master ● ?8 ~2]-ff tf state list
No state file was found!

State management commands require a state file. Run this command
in a directory where Terraform has been run or use the -state flag
to point the command to a specific state location.

Terraform Deploy

To deploy new changes you can run terraform apply but understand that this will change the infrastructure. If you just want to see if there are any pending changes it is best to use terraform plan as this will not give you the opportuinity to confrim and deploy only to see changes.

Post deployment

Once deployed you can check that terraform is now managing the state by running terraform state list from here you will get an output of all of the resouces deployed.

After deployment you will need to generate client id and secrets for access to the azure monitoring. It is best practice to grant least privilage so in this case running az ad sp create-for-rbac --role="Log Analytics Reader" --scopes="/subscriptions/<subscription_id> will create your id and secret as a read only for log analytics.

Opening the portal for the FQDN on port 3000 will ask you to set an admin password. Navigate to settings > data sources > add data source > azure monitor. Enter the tenant id, client id and secret.

Connect to and Monitor AZ Container

  • connecting to the container you can run az container exec --resource-group LightHouseMonitoring-rg --name grafana-instance --exec-command "/bin/bash"
  • to view the logs from the container az container logs --resource-group LightHouseMonitoring-rg --name grafana-instance

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages