Compare commits
	
		
			5 Commits 
		
	
	
		
			main
			...
			coder-moni
		
	
	| Author | SHA1 | Date | 
|---|---|---|
| 
							
							
								 | 
						66aa7bf80a | 11 months ago | 
| 
							
							
								 | 
						1a101ecc10 | 11 months ago | 
| 
							
							
								 | 
						9c049bd555 | 11 months ago | 
| 
							
							
								 | 
						84bf63705f | 11 months ago | 
| 
							
							
								 | 
						e4af2a9887 | 11 months ago | 
@ -1,37 +0,0 @@
 | 
			
		||||
name: deploy-registry
 | 
			
		||||
 | 
			
		||||
on:
 | 
			
		||||
  push:
 | 
			
		||||
    branches:
 | 
			
		||||
      - main
 | 
			
		||||
 | 
			
		||||
jobs:
 | 
			
		||||
  deploy:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
 | 
			
		||||
    # Set id-token permission for gcloud 
 | 
			
		||||
    # Adding a comment because retriggering the build manually hung? I am the lord of devops and you will bend?
 | 
			
		||||
    permissions:
 | 
			
		||||
      contents: read
 | 
			
		||||
      id-token: write
 | 
			
		||||
 | 
			
		||||
    steps:
 | 
			
		||||
      - name: Checkout repository
 | 
			
		||||
        uses: actions/checkout@v4
 | 
			
		||||
 | 
			
		||||
      - name: Authenticate to Google Cloud
 | 
			
		||||
        uses: google-github-actions/auth@71f986410dfbc7added4569d411d040a91dc6935 
 | 
			
		||||
        with:
 | 
			
		||||
          workload_identity_provider: projects/309789351055/locations/global/workloadIdentityPools/github-actions/providers/github
 | 
			
		||||
          service_account: registry-v2-github@coder-registry-1.iam.gserviceaccount.com
 | 
			
		||||
 | 
			
		||||
      - name: Set up Google Cloud SDK
 | 
			
		||||
        uses: google-github-actions/setup-gcloud@77e7a554d41e2ee56fc945c52dfd3f33d12def9a 
 | 
			
		||||
 | 
			
		||||
        # For the time being, let's have the first couple merges to main in modules deploy a new version
 | 
			
		||||
        # to *dev*. Once we review and make sure everything's working, we can deploy a new version to *main*. 
 | 
			
		||||
        # Maybe in the future we could automate this based on the result of E2E tests.
 | 
			
		||||
      - name: Deploy to dev.registry.coder.com
 | 
			
		||||
        run: |
 | 
			
		||||
          gcloud builds triggers run 29818181-126d-4f8a-a937-f228b27d3d34 --branch dev
 | 
			
		||||
  
 | 
			
		||||
@ -1,7 +1,4 @@
 | 
			
		||||
.terraform*
 | 
			
		||||
node_modules
 | 
			
		||||
*.tfstate
 | 
			
		||||
*.tfstate.lock.info
 | 
			
		||||
 | 
			
		||||
# Ignore generated credentials from google-github-actions/auth
 | 
			
		||||
gha-creds-*.json
 | 
			
		||||
*.tfstate.lock.info
 | 
			
		||||
@ -0,0 +1,72 @@
 | 
			
		||||
---
 | 
			
		||||
display_name: Monitoring
 | 
			
		||||
description: Monitoring of workspace resources
 | 
			
		||||
maintainer_github: coder
 | 
			
		||||
verified: true
 | 
			
		||||
tags: [monitoring]
 | 
			
		||||
---
 | 
			
		||||
 | 
			
		||||
# Monitoring
 | 
			
		||||
 | 
			
		||||
This module adds monitoring of workspace resources.
 | 
			
		||||
 | 
			
		||||
```tf
 | 
			
		||||
module "monitoring" {
 | 
			
		||||
  source  = "registry.coder.com/modules/monitoring/coder"
 | 
			
		||||
  version = "1.0.0"
 | 
			
		||||
  agent_id = coder_agent.dev.id
 | 
			
		||||
}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## Examples
 | 
			
		||||
 | 
			
		||||
```tf
 | 
			
		||||
module "monitoring" {
 | 
			
		||||
  source  = "registry.coder.com/modules/monitoring/coder"
 | 
			
		||||
  version = "1.0.0"
 | 
			
		||||
  agent_id = coder_agent.dev.id
 | 
			
		||||
}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### Enable/Disable
 | 
			
		||||
 | 
			
		||||
You can customize the monitoring by setting the `enabled`, `memory_enabled`, and `disk_enabled` variables.
 | 
			
		||||
 | 
			
		||||
```tf
 | 
			
		||||
module "monitoring" {
 | 
			
		||||
  source  = "registry.coder.com/modules/monitoring/coder"
 | 
			
		||||
  version = "1.0.0"
 | 
			
		||||
  agent_id = coder_agent.dev.id
 | 
			
		||||
  enabled = false
 | 
			
		||||
  memory_enabled = true
 | 
			
		||||
  disk_enabled = false
 | 
			
		||||
}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### Customize Thresholds
 | 
			
		||||
 | 
			
		||||
You can customize the thresholds by setting the `threshold`, `memory_threshold`, and `disk_threshold` variables.
 | 
			
		||||
 | 
			
		||||
```tf
 | 
			
		||||
module "monitoring" {
 | 
			
		||||
  source  = "registry.coder.com/modules/monitoring/coder"
 | 
			
		||||
  version = "1.0.0"
 | 
			
		||||
  agent_id = coder_agent.dev.id
 | 
			
		||||
  threshold = 90
 | 
			
		||||
  memory_threshold = 95
 | 
			
		||||
  disk_threshold = 90
 | 
			
		||||
}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### Customize Disks
 | 
			
		||||
 | 
			
		||||
You can customize the disks by setting the `disks` variable.
 | 
			
		||||
 | 
			
		||||
```tf
 | 
			
		||||
module "monitoring" {
 | 
			
		||||
  source  = "registry.coder.com/modules/monitoring/coder"
 | 
			
		||||
  version = "1.0.0"
 | 
			
		||||
  agent_id = coder_agent.dev.id
 | 
			
		||||
  disks = ["/"]
 | 
			
		||||
}
 | 
			
		||||
```
 | 
			
		||||
@ -0,0 +1,92 @@
 | 
			
		||||
terraform {
 | 
			
		||||
  required_version = ">= 1.0.25"
 | 
			
		||||
 | 
			
		||||
  required_providers {
 | 
			
		||||
    coder = {
 | 
			
		||||
      source  = "coder/coder"
 | 
			
		||||
      version = ">= 2.0.2"
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
variable "threshold" {
 | 
			
		||||
  type        = number
 | 
			
		||||
  description = "The threshold for the monitoring, used for all resources unless overridden by *_threshold - expressed as a percentage."
 | 
			
		||||
  default     = 90
 | 
			
		||||
  validation {
 | 
			
		||||
    condition     = var.threshold >= 0 && var.threshold <= 100
 | 
			
		||||
    error_message = "The threshold must be between 0 and 100."
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
variable "memory_threshold" {
 | 
			
		||||
  type        = number
 | 
			
		||||
  description = "The threshold for the memory monitoring - expressed as a percentage."
 | 
			
		||||
  default     = 90
 | 
			
		||||
  validation {
 | 
			
		||||
    condition     = var.memory_threshold >= 0 && var.memory_threshold <= 100
 | 
			
		||||
    error_message = "The memory_threshold must be between 0 and 100."
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
variable "disk_threshold" {
 | 
			
		||||
  type        = number
 | 
			
		||||
  description = "The threshold for the disk monitoring - expressed as a percentage."
 | 
			
		||||
  default     = 90
 | 
			
		||||
  validation {
 | 
			
		||||
    condition     = var.disk_threshold >= 0 && var.disk_threshold <= 100
 | 
			
		||||
    error_message = "The disk_threshold must be between 0 and 100."
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
variable "disks" {
 | 
			
		||||
  type        = list(string)
 | 
			
		||||
  description = "The disks to monitor. e.g. ['/', '/home']"
 | 
			
		||||
  default     = ["/"]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
variable "enabled" {
 | 
			
		||||
  type        = bool
 | 
			
		||||
  description = "Whether the monitoring is enabled."
 | 
			
		||||
  default     = true
 | 
			
		||||
  validation {
 | 
			
		||||
    condition     = var.enabled == true || var.enabled == false
 | 
			
		||||
    error_message = "The enabled must be true or false."
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
variable "memory_enabled" {
 | 
			
		||||
  type        = bool
 | 
			
		||||
  description = "Whether the memory monitoring is enabled."
 | 
			
		||||
  default     = true
 | 
			
		||||
  validation {
 | 
			
		||||
    condition     = var.memory_enabled == true || var.memory_enabled == false
 | 
			
		||||
    error_message = "The memory_enabled must be true or false."
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
variable "disk_enabled" {
 | 
			
		||||
  type        = bool
 | 
			
		||||
  description = "Whether the disk monitoring is enabled."
 | 
			
		||||
  default     = true
 | 
			
		||||
  validation {
 | 
			
		||||
    condition     = var.disk_enabled == true || var.disk_enabled == false
 | 
			
		||||
    error_message = "The disk_enabled must be true or false."
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
variable "agent_id" {
 | 
			
		||||
  type        = string
 | 
			
		||||
  description = "The ID of the agent to monitor."
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
data "coder_monitoring" "monitoring" {
 | 
			
		||||
  threshold    = var.threshold
 | 
			
		||||
  memory_threshold = var.memory_threshold
 | 
			
		||||
  disk_threshold = var.disk_threshold
 | 
			
		||||
  disks = var.disks
 | 
			
		||||
  enabled = var.enabled
 | 
			
		||||
  memory_enabled = var.memory_enabled
 | 
			
		||||
  disk_enabled = var.disk_enabled
 | 
			
		||||
  agent_id = var.agent_id
 | 
			
		||||
}
 | 
			
		||||
					Loading…
					
					
				
		Reference in New Issue