When moving from a dev or staging env it could be quite useful to be able to export templates and import them back into the new environment. There is no support for this currently, either through the UI or via the Remote API/CLI.
test
This bug was previously known as http://jira.rhq-project.org/browse/RHQ-2485
It would also be nice to have the ability to put/set AlertDefinition to persist changes back to the server via CLI. For example, add an updateAlertDefinition and createAlertDefinition method to interface AlertDefinitionManagerRemote. The idea is to allow one to update an existing alert and/or define new alerts.
The feature of ex/importing "Metric templates" from CLI is implemented now. Adding alerts in this feature it is indeed difficult as they depend on inventory, but "alert definition templates" do not depend on inventory, so I think this should be considered to add in export/import feature.
From JON product management discussion regarding this feature: Charles Crouch added a comment - 05/Jun/12 11:21 AM Alert definitions came up as a topic of import/export during work in that area for JON3.0. One of the difficulties with alert templates is around notifications which reference specific resources e.g. fire an operation on a specific resource. We could support a subset of all alert templates (those which don't reference specific resources) but we need to explain/doc/handle somehow the situation the other cases.
Hello, I have developed a server plugin which exports/imports alert definitions in an XML file. I attach the artifact if you want to have a look. The plugin has some issues which I describe below, still I think it worth to discuss the idea. The usage is simple: - in the "Plugin configuration" section it is defined the file to export/import definitions; it is an XML file. - in the "Controls" section there is a combo-box where you can select the desired operation: export or import. Select an operation then click on the small green button which appears right next to combo. The result of the operation will be displayed below the combo. Issues: 1. it is only accesible to admins 2. the file is on the RHQ server machine, not accessible for normal operators 3. it exports all defs, cannot be filtered to export only defs of a resource/group or defs of a resource type 4. it works with defs on resources, not on groups. It should work on groups because we have to have the possibility to modify them on group level. Possible solutions: 1. give operators necessary privilege to access it -> may not be acceptable, it would mean to give to much power on RHQ server. Or keep it as an operation only for admins. 2. make the plugin to download/upload file from browser -> not possible because of plugin technical limitations; possible to be done but it would require modifications in GUI core code which is beyond the scope of a plugin. 3. make the plugin configurable by providing a dialog box where user could select a resource -> not possible for the same reason as above. 4. can be done, with the condition that the groups has to exist (have the same name) in both source and target RHQ instances. Which is normal actually, they should. Best regards, Vlad
Created attachment 790529 [details] import/export alert definitions plugin
Hello Vlad, we have run into a definite need for having export/import of Alert Templates. I have tried your plugin and it works -but it exports all the defined alterts for all resources, which is not quite what we want. Is there a way to have it just export the *templates* and have RHQ set them for all resources the standard way later? Is it possible to trim out the resource-specific config from the XML so you are left with just the templates? Thanks for the plugin, I think it is most promising :) -STian
Hello Stian, Yes, is possible to export/import only templates, I am working on this. I am glad you find this plugin useful, hope the RHQ guys will give feedback about it.
Thanks for the information Vlad - I will be very happy to test it for you when you have something.
Created attachment 844911 [details] server plugin for exporting/importing alert definitions I finally got some time for this task. The plugin is now able to handle all types of alert definitions: on resource type (template), on group of resources and on single resource. There is the possiblity to export templates only.
Thanks Vlad - I will have a look at this plugin the first chance I get, probably next week. cheers, Stian
Hello Vlad. I have tested a bit - and a question or two: 1. It only works in RHQ 4.7 and up? Because I have tried installing the plugin in RHQ 4.5.1 and it does not show up. Just wondering what versions are "supported"? 2. The "Working File" would be nice if it was either set blank to remind users they have to fill a value there, it is easy to forget and not sure where file ends up. Would be better if it writes to either the RHQ install directory, or some kind of directory which is standard, maybe $HOME (but not on Windows obv.) Or the RHQ runtime directory. For instance, if full path is not given, for me on Linux it ends up at /opt/rhq/rhq-server/jbossas/bin, which is RHQ Runtime directory. 3. Related to point above, if "Working file" cannot be written or it fails it would be good to be able to read the error message, like "permission denied" etc. Maybe by clicking on red failure image to get exception text. It seems to work, but I have yet to try actually export/import of the Alerts we use, as the Test-environment is the only 4.9 install, the rest are 4.5.1. Example of a default export def for 4.9 Storage alert: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <alertDefinitionWrappers> <values> <id>0</id> <name>StorageNodeMaintenanceOperationsFailure</name> <ctime>0</ctime> <mtime>0</mtime> <parentId>0</parentId> <description>Maintenance operation failed for an RHQ Storage Node. When fired please see documentation for the proper corrective action.</description> <priority>MEDIUM</priority> <enabled>true</enabled> <alertDampening> <category>NONE</category> <period>0</period> <value>0</value> </alertDampening> <recoveryId>0</recoveryId> <willRecover>false</willRecover> <notifyFiltered>false</notifyFiltered> <controlFiltered>false</controlFiltered> <deleted>false</deleted> <readOnly>false</readOnly> <conditionExpression>ANY</conditionExpression> <conditionWrappers> <id>0</id> <category>CONTROL</category> <name>addNodeMaintenance</name> <option>FAILURE</option> </conditionWrappers> <conditionWrappers> <id>0</id> <category>CONTROL</category> <name>removeNodeMaintenance</name> <option>FAILURE</option> </conditionWrappers> <conditionWrappers> <id>0</id> <category>CONTROL</category> <name>readRepair</name> <option>FAILURE</option> </conditionWrappers> <conditionWrappers> <id>0</id> <category>CONTROL</category> <name>updateConfiguration</name> <option>FAILURE</option> </conditionWrappers> <conditionWrappers> <id>0</id> <category>CONTROL</category> <name>updateSeedsList</name> <option>FAILURE</option> </conditionWrappers> <conditionWrappers> <id>0</id> <category>CONTROL</category> <name>announce</name> <option>FAILURE</option> </conditionWrappers> <conditionWrappers> <id>0</id> <category>CONTROL</category> <name>prepareForUpgrade</name> <option>FAILURE</option> </conditionWrappers> <conditionWrappers> <id>0</id> <category>CONTROL</category> <name>prepareForBootstrap</name> <option>FAILURE</option> </conditionWrappers> <conditionWrappers> <id>0</id> <category>CONTROL</category> <name>unannounce</name> <option>FAILURE</option> </conditionWrappers> <groupAlertDefinitionId>-1</groupAlertDefinitionId> <resourceTypeName>RHQ Storage Node</resourceTypeName> <resourceTypePluginName>RHQStorage</resourceTypePluginName> </values> <values> <id>0</id> <name>StorageNodeHighHeapTemplate</name> <ctime>0</ctime> <mtime>0</mtime> <parentId>0</parentId> <priority>MEDIUM</priority> <enabled>true</enabled> <alertDampening> <category>PARTIAL_COUNT</category> <period>15</period> <periodUnits>MINUTES</periodUnits> <value>10</value> </alertDampening> <recoveryId>0</recoveryId> <willRecover>false</willRecover> <notifyFiltered>false</notifyFiltered> <controlFiltered>false</controlFiltered> <deleted>false</deleted> <readOnly>false</readOnly> <conditionExpression>ANY</conditionExpression> <conditionWrappers> <id>0</id> <category>THRESHOLD</category> <name>Heap Usage Percentage</name> <comparator>></comparator> <threshold>0.75</threshold> <mDefCategory>PERFORMANCE</mDefCategory> <mDefDataType>MEASUREMENT</mDefDataType> <mDefName>Calculated.HeapUsagePercentage</mDefName> <mDefPlugin>RHQStorage</mDefPlugin> <mDefResTypeName>VM Memory System</mDefResTypeName> </conditionWrappers> <groupAlertDefinitionId>-1</groupAlertDefinitionId> <resourceTypeName>VM Memory System</resourceTypeName> <resourceTypePluginName>RHQStorage</resourceTypePluginName> </values> <values> <id>0</id> <name>StorageNodeHighDiskUsageTemplate</name> <ctime>0</ctime> <mtime>0</mtime> <parentId>0</parentId> <description>An alert template to notify users of excessive heap use by an RHQ Storage Node. When fired please see documentation for the proper corrective action.</description> <priority>MEDIUM</priority> <enabled>true</enabled> <alertDampening> <category>PARTIAL_COUNT</category> <period>15</period> <periodUnits>MINUTES</periodUnits> <value>10</value> </alertDampening> <recoveryId>0</recoveryId> <willRecover>false</willRecover> <notifyFiltered>false</notifyFiltered> <controlFiltered>false</controlFiltered> <deleted>false</deleted> <readOnly>false</readOnly> <conditionExpression>ANY</conditionExpression> <conditionWrappers> <id>0</id> <category>THRESHOLD</category> <name>Total Disk Used Percentage</name> <comparator>></comparator> <threshold>0.75</threshold> <mDefCategory>PERFORMANCE</mDefCategory> <mDefDataType>MEASUREMENT</mDefDataType> <mDefName>Calculated.TotalDiskUsedPercentage</mDefName> <mDefPlugin>RHQStorage</mDefPlugin> <mDefResTypeName>StorageService</mDefResTypeName> </conditionWrappers> <conditionWrappers> <id>0</id> <category>THRESHOLD</category> <name>Free Disk to Data Size Ratio</name> <comparator><</comparator> <threshold>1.5</threshold> <mDefCategory>PERFORMANCE</mDefCategory> <mDefDataType>MEASUREMENT</mDefDataType> <mDefName>Calculated.FreeDiskToDataSizeRatio</mDefName> <mDefPlugin>RHQStorage</mDefPlugin> <mDefResTypeName>StorageService</mDefResTypeName> </conditionWrappers> <conditionWrappers> <id>0</id> <category>THRESHOLD</category> <name>Data File Disk Used Percentage</name> <comparator>></comparator> <threshold>0.5</threshold> <mDefCategory>PERFORMANCE</mDefCategory> <mDefDataType>MEASUREMENT</mDefDataType> <mDefName>Calculated.DataDiskUsedPercentage</mDefName> <mDefPlugin>RHQStorage</mDefPlugin> <mDefResTypeName>StorageService</mDefResTypeName> </conditionWrappers> <groupAlertDefinitionId>-1</groupAlertDefinitionId> <resourceTypeName>StorageService</resourceTypeName> <resourceTypePluginName>RHQStorage</resourceTypePluginName> </values> <values> <id>0</id> <name>StorageNodeSnapshotFailureTemplate</name> <ctime>0</ctime> <mtime>0</mtime> <parentId>0</parentId> <description>An alert template to notify users when a snapshot operations fails for an RHQ Storage Node. When fired please see documentation for the proper corrective action.</description> <priority>MEDIUM</priority> <enabled>true</enabled> <alertDampening> <category>NONE</category> <period>0</period> <value>0</value> </alertDampening> <recoveryId>0</recoveryId> <willRecover>false</willRecover> <notifyFiltered>false</notifyFiltered> <controlFiltered>false</controlFiltered> <deleted>false</deleted> <readOnly>false</readOnly> <conditionExpression>ANY</conditionExpression> <conditionWrappers> <id>0</id> <category>CONTROL</category> <name>takeSnapshot</name> <option>FAILURE</option> </conditionWrappers> <groupAlertDefinitionId>-1</groupAlertDefinitionId> <resourceTypeName>StorageService</resourceTypeName> <resourceTypePluginName>RHQStorage</resourceTypePluginName> </values> </alertDefinitionWrappers>
Hello Stian, I only worked/tested on 4.7, I don't know what happens on other versions, though I would have expected to work. I will try to figure this out. Related to the points about the file, I agree with you. I will address them. Best regards, Vlad
Don't worry so much about it working on older versions pre 4.7. It's more important that the plugin works on 4.9 and 4.10 (when it's out) :) Below is an example of a typical alert we create for Down deployments on JBoss AS7. It looks like it's working, and I will try to delete it and then import again. A question: - How will the plugin handle if alerts with the same name already exists? <values> <id>0</id> <name>JBoss-Deployment-DOWN</name> <ctime>0</ctime> <mtime>0</mtime> <parentId>0</parentId> <description>JBoss Deployment DOWN</description> <priority>HIGH</priority> <enabled>true</enabled> <alertDampening> <category>CONSECUTIVE_COUNT</category> <period>0</period> <value>3</value> </alertDampening> <recoveryId>0</recoveryId> <willRecover>false</willRecover> <notifyFiltered>false</notifyFiltered> <controlFiltered>false</controlFiltered> <deleted>false</deleted> <readOnly>false</readOnly> <conditionExpression>ANY</conditionExpression> <alertNotifications> <configuration> <id>104727</id> <version>0</version> <ctime>1390817903548</ctime> <mtime>1390817903548</mtime> <propertySimple> <id>3460503</id> <name>emailAddress</name> <stringValue>rhqadmin</stringValue> </propertySimple> </configuration> <extraConfiguration> <id>104728</id> <version>0</version> <ctime>1390817903551</ctime> <mtime>1390817903551</mtime> </extraConfiguration> <senderName>Direct Emails</senderName> </alertNotifications> <conditionWrappers> <id>0</id> <category>AVAIL_DURATION</category> <name>AVAIL_DURATION_DOWN</name> <option>600</option> </conditionWrappers> <groupAlertDefinitionId>-1</groupAlertDefinitionId> <resourceTypeName>Deployment</resourceTypeName> <resourceTypePluginName>JBossAS7</resourceTypePluginName> </values>
When I do an import of the Alert definition, after deleting the existing one, i get the following: org.rhq.enterprise.server.alert.AlertDefinitionCreationException: Could not create alertTemplate for ResourceType[id=10388, name=DeploymentScanner, plugin=JBossAS7, category=Service] with data AlertDefinition[ id=10138, name=JBoss-Deployment-DOWN ] Description: gigi