0

Update View

by
Published Oct 17, 2025

Use this method to update a view. You can change the view configuration details; add or remove view specific alerts; or attach and detach preset alerts.

Script mezmo Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Update View
4
 * Use this method to update a view. You can change the view configuration details; add or remove view specific alerts; or attach and detach preset alerts.
5
 */
6
export async function main(auth: RT.Mezmo, viewId: string, body: Body) {
7
	const url = new URL(`https://api.mezmo.com/v1/config/view/${viewId}`)
8

9
	const response = await fetch(url, {
10
		method: 'PUT',
11
		headers: {
12
			'Content-Type': 'application/json',
13
			Authorization: 'Token ' + auth.apiKey
14
		},
15
		body: JSON.stringify(body)
16
	})
17
	if (!response.ok) {
18
		const text = await response.text()
19
		throw new Error(`${response.status} ${text}`)
20
	}
21
	return await response.json()
22
}
23

24
/* eslint-disable */
25
/**
26
 * This file was automatically generated by json-schema-to-typescript.
27
 * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
28
 * and run json-schema-to-typescript to regenerate this file.
29
 */
30

31
export interface Body {
32
	/**
33
	 * Name of a view.
34
	 */
35
	name: string
36
	/**
37
	 * Search query.
38
	 */
39
	query?: string
40
	hosts?: string[]
41
	apps?: string[]
42
	levels?: string[]
43
	tags?: string[]
44
	category?: string[]
45
	/**
46
	 * ID of a preset alert.
47
	 */
48
	presetid?: string
49
	channels?: {
50
		/**
51
		 * Defines the type of notification channel. Valid values are: `email`, `webhook`, `slack`, and `pagerduty`
52
		 */
53
		integration?: string
54
		emails?: string[]
55
		/**
56
		 * Webhook URL.
57
		 */
58
		url?: string
59
		/**
60
		 * PagerDuty key.
61
		 */
62
		key?: string
63
		/**
64
		 * Specify the number of log lines that match the view's filtering and search criteria. When the number of log lines is reached, an alert is triggered.
65
		 */
66
		triggerlimit?: string
67
		/**
68
		 * Specify how often to trigger an alert. Valid values are: 30 seconds, 1 minute, 5 minutes, 15 minutes, 30 minutes, 1 hour, 6 hours, 12 hours, 24 hours
69
		 */
70
		triggerinterval?: string
71
		/**
72
		 * Set to true if you want the trigger condition to be evaluated as soon as the triggerlimit is reached.
73
		 */
74
		immediate?: boolean
75
		/**
76
		 * Set to true if you want the trigger condition to be evaluated after the time that you specify in the triggerinterval field is reached.
77
		 */
78
		terminal?: boolean
79
		/**
80
		 * Type of alert. Valid values are: `presence`and `absence`.
81
		 */
82
		operator?: string
83
		/**
84
		 * Timezone used to report timestamps. This can be any value defined in the tz database https://en.wikipedia.org/wiki/List_of_tz_database_time_zones.
85
		 */
86
		timezone?: string
87
		/**
88
		 * WebHook method such as POST.
89
		 */
90
		method?: 'POST' | 'PUT' | 'PATCH'
91
		headers?: {
92
			/**
93
			 * Header value
94
			 */
95
			timestamp?: string
96
			[k: string]: unknown
97
		}
98
		bodyTemplate?: {
99
			/**
100
			 * Define the webhook body.
101
			 */
102
			timestamp?: string
103
			[k: string]: unknown
104
		}
105
		/**
106
		 * Set to true if you want the set a condition to resolve the incident that was raised by this alert.  This property only applies to PagerDuty.
107
		 */
108
		autoresolve?: boolean
109
		/**
110
		 * Interval of time to aggregate and check # of matched lines against the auto resolve limit. Valid values are: 30 seconds, 1 minute, 5 minutes, 15 minutes, 30 minutes, 1 hour, 6 hours, 12 hours, 24 hours, 25 hours.
111
		 */
112
		autoresolveinterval?: string
113
		/**
114
		 * Specify the number of log lines that match the view's filtering and search criteria. When the number of log lines is reached, this incident will be set to resolved in PagerDuty.
115
		 */
116
		autoresolvelimit?: string
117
		[k: string]: unknown
118
	}[]
119
	[k: string]: unknown
120
}
121