[ZBXNEXT-1679] value mapping xml import/export Created: 2013 Mar 21  Updated: 2016 Feb 01  Resolved: 2016 Feb 01

Status: Closed
Project: ZABBIX FEATURE REQUESTS
Component/s: API (A), Frontend (F)
Affects Version/s: 2.0.5
Fix Version/s: 3.0.0alpha4

Type: New Feature Request Priority: Minor
Reporter: Michal Ingeli Assignee: Unassigned
Resolution: Fixed Votes: 39
Labels: export, valuemapping, xml
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by ZBXNEXT-2630 Add value mappings into exported temp... Closed
is duplicated by ZBX-8637 error while importing default templat... Closed

 Description   

When exporting template, configured value mapping should also be exported. There may be custom mappings configured.

When importing, rules should provide option to update/add missing value mappings from xml exported template.

Specification



 Comments   
Comment by richlv [ 2013 Jun 06 ]

it shouldn't be limited to templates - host import/export might benefit as well.
but primarily the xml import/export of valuemaps themselves must appear

Comment by richlv [ 2013 Jun 06 ]

ZBXNEXT-1424 asks for valuemap api

Comment by Raymond Kuiper [ 2013 Dec 03 ]

I was shocked to see that this wasn't included in 2.2 (at least not in the value mapping admin screen). I just spend a lot of time typing in all the HTTP response codes, would have been handy to make an export for future use...

Comment by Raymond Kuiper [ 2013 Dec 06 ]

If you are interested in this feature, ZBXNEXT-2063 might be interesting too.

Comment by sergio cricca [ 2014 May 21 ]

it would be useful to have import/export feature (like that in hosts/templates configuration) into administration/Value mapping page, as well as exporting/importing when working with templates.

same thing could be usefull with "regular expressions".. no way to export/import them.

Comment by Marc [ 2014 May 21 ]

ZBXNEXT-2313 asks for "export/import "regular expressions" feature [...]"

Comment by Filipe Paternot [ 2014 Jun 06 ]

Both features (ZBXNEXT-1679 and ZBXNEXT-2313) are very needed to create the possibility of exchanging templates between zabbix instances.
This would mean that we could share complete templates (with value maps and regexps) to the community and so on! This is true open source

Comment by Joris Willems [ 2014 Aug 20 ]

Still an issue. Import-export feature is not working if it isn't finished. Is zabbix really ready for production if the core functionalities advertised on the website are not working?

http://www.zabbix.com/template_import_export.php

Comment by Otheus [ 2015 Jul 20 ]

I wouldn't say this is critical, but it is an error that Zabbix reports as an error the lack of an existing map during import. A patch to produce a warning and not error would be sufficient to alleviate the problems for the short-term.

Comment by Ivo Kurzemnieks [ 2015 Oct 27 ]

(1) Translation strings added:

  • Value maps deleted
  • Cannot delete value maps
  • Value mappings
  • Value mappings for value maps will be updated!
  • Delete selected value maps?

sasha CLOSED

iivs Added translation string:

  • Used in items

sasha CLOSED

Comment by Ivo Kurzemnieks [ 2015 Oct 27 ]

RESOLVED in svn://svn.zabbix.com/branches/dev/ZBXNEXT-1679

Comment by Alexander Vladishev [ 2015 Nov 02 ]

(2) valuemap.massdelete must be renamed to valuemap.delete

iivs RESOLVED in r56475

sasha CLOSED

Comment by Alexander Vladishev [ 2015 Nov 02 ]

(3) valuemap.delete also must be used instead of the delete parameter; delete should be removed

iivs RESOLVED in r56475

sasha CLOSED

Comment by Alexander Vladishev [ 2015 Nov 02 ]

(5) "Undefined index" if $config['search_limit'] has small value

Undefined index: valuemapid [adm.valuemapping.php:214 → CView->render() → include() in include/views/administration.general.valuemapping.list.php:56]
Undefined index: valuemapid [adm.valuemapping.php:214 → CView->render() → include() in include/views/administration.general.valuemapping.list.php:56]
Undefined index: name [adm.valuemapping.php:214 → CView->render() → include() in include/views/administration.general.valuemapping.list.php:57]
Undefined index: valuemapid [adm.valuemapping.php:214 → CView->render() → include() in include/views/administration.general.valuemapping.list.php:57]

iivs RESOLVED in r56499

sasha CLOSED

Comment by Alexander Vladishev [ 2015 Nov 02 ]

(6) overlayDialog sould be extended to support action on ESC and [x] button click. It must reset check box.

iivs RESOLVED in r56480

sasha

  • fixed order of the buttons
  • added "cancel" flag in all calls of the overlayDialog()
  • code improvements

RESOLVED in r56491

iivs I completely disagree with button order. Feels wrong. Usually the dialogue button order depends on OS UI. Some systems use OK as first button and then Cancel. Also JIRA has first Save button and then Cancel button. Now the order of buttons is built in and Cancel is first button and then OK button. But as discussed, sadly it will not be changed for now.

CLOSED

Comment by Alexander Vladishev [ 2015 Nov 02 ]

(7) This code does not work properly. It is not associative array.

frontends/php/include/classes/export/CConfigurationExport.php:451

$valuemapids = zbx_objectValues($items, 'valuemapid');

foreach ($valuemapids as $valuemapid) {
    if ($valuemapid == 0) {
        unset($valuemapids[$valuemapid]);
    }
}

$valuemapids = array_combine($valuemapids, $valuemapids);

and

frontends/php/include/classes/export/CConfigurationExport.php:589

// Gather value maps. Value map IDs that are zeroes, should be skipped
$valuemapids = zbx_objectValues($prototypes, 'valuemapid');           
     
foreach ($valuemapids as $valuemapid) {
    if ($valuemapid == 0) {                           
        unset($valuemapids[$valuemapid]);            
    }                                                             
}                               
                       
$valuemapids = array_combine($valuemapids, $valuemapids);

iivs RESOLVED in r56484

sasha Take a look at my changes in r56493.

iivs Good solution. Thanks!
CLOSED

Comment by Alexander Vladishev [ 2015 Nov 02 ]

(8) Unused code

frontends/php/include/classes/export/CConfigurationExport.php:467
frontends/php/include/classes/export/CConfigurationExport.php:606

$valuemaps = $this->data['valueMaps'];

iivs RESOLVED in r56486

sasha CLOSED

Comment by Alexander Vladishev [ 2015 Nov 02 ]

(9) + operator must be used here because it works faster.

frontends/php/include/classes/export/CConfigurationExport.php:484

$this->data['valueMaps'] = zbx_array_merge($this->data['valueMaps'], $valuemaps);

iivs RESOLVED in r56488, r56489

sasha CLOSED

Comment by Alexander Vladishev [ 2015 Nov 02 ]

(10) This code must be located in beginning of the function (before processing of value maps).

frontends/php/include/classes/export/CConfigurationExport.php:494

// Remove items linked to discovered applications.
foreach ($item['applications'] as $application) {
    if ($application['flags'] == ZBX_FLAG_DISCOVERY_CREATED) {
        unset($items[$idx]);
        continue 2;
    }
}

iivs RESOLVED in r56490

sasha CLOSED

Comment by Alexander Vladishev [ 2015 Nov 02 ]

(11) "Update existing" must be unchecked by default when importing value maps. Specification must be updated accordingly.

iivs Specification updated and RESOLVED in r56502

sasha CLOSED

Comment by Alexander Vladishev [ 2015 Nov 02 ]

(12) <mappings> tag must be REQUIRED

iivs RESOLVED in r56503

sasha CLOSED

Comment by Alexander Vladishev [ 2015 Nov 02 ]

(13) Permissions check must be removed in:

frontends/php/include/classes/export/CConfigurationExport.php:183
frontends/php/include/classes/import/CConfigurationImport.php:603

iivs Specification updated and RESOLVED in r56504

sasha CLOSED

Comment by Alexander Vladishev [ 2015 Nov 02 ]

(14) Take a look at my changes in r56445, r56468 and r56477.

iivs Thanks! Good improvements.
CLOSED

Comment by richlv [ 2015 Nov 03 ]

(15) when this is done, all official templates that reference value maps should be updated to include those value maps

sasha It about Zabbix Templates/Official Templates page? There are no 3.0 templates.

<richlv> yes, in that page 3.0 templates should be added - but only the ones that reference value maps

sasha may be after release of 3.0.0?

<richlv> after 3.0.0 final would be a bit too late - but after beta1 is out could be a good time

sasha Ok, it can be closed now.

CLOSED

Comment by richlv [ 2015 Nov 03 ]

(16) documentation

iivs Also should be good to look at:

And don't forget:

iivs Docs updated:
https://www.zabbix.com/documentation/3.0/manual/api/reference/configuration/import
https://www.zabbix.com/documentation/3.0/manual/api/reference/configuration/export
https://www.zabbix.com/documentation/3.0/manual/xml_export_import/hosts
https://www.zabbix.com/documentation/3.0/manual/xml_export_import#what_can_be_exportedimported

<richlv> thanks. the new column, "used in items", does not seem to be mentioned in the whatsnew

martins-v Added to https://www.zabbix.com/documentation/3.0/manual/introduction/whatsnew300#exporting_and_importing_value_maps

Official documentation seems to be updated. RESOLVED

asaveljevs The XML in the example at https://www.zabbix.com/documentation/3.0/manual/api/reference/configuration/import and https://www.zabbix.com/documentation/3.0/manual/api/reference/configuration/export seems suspicious:

"source": "<?xml version="1.0" encoding="UTF-8"?><!--?xml version=\"1.0\" encoding=\"UTF-8\"?--><zabbix_export>...

"result": "<!--?xml version=\"1.0\" encoding=\"UTF-8\"?-->\n<zabbix_export>...

Also, the following Zabbix.org pages seems to have not been updated as per richlv's suggestion: https://zabbix.org/wiki/Zabbix_Templates/Official_Templates and https://zabbix.org/wiki/Zabbix_Templates/SQLs_for_Official_Templates . REOPENED.

iivs import/export examples RESOLVED

asaveljevs On the import page, the double quotes in XML are not properly quoted for JSON:

"source": "<?xml version="1.0" encoding="UTF-8"?><zabbix_export>...

REOPENED

iivs Indeed. Sorry. RESOLVED

martins-v Updated as well:

Please review. RESOLVED

asaveljevs Looks good. CLOSED.

Comment by Alexander Vladishev [ 2015 Nov 03 ]

(17) Default selection of the "Create new" value maps in the Host and Template import forms must be discussed

sasha Already discussed with richlv. "Create new" rule must be selected by default. Specification is updated accordingly.

iivs RESOLVED in r56512

sasha CLOSED

Comment by Alexander Vladishev [ 2015 Nov 04 ]

(18) "USED IN ITEMS" column must be added to display using value mappings in items and item prototypes. Column name should be accepted by martins-v. Specification must be updated.

iivs Specification updated and RESOLVED in r56529

martins-v "Used in items" sounds good to me.

sasha Take a look at my changes in r56553.

iivs Thanks! Good performance improvement.
CLOSED

Comment by Ivo Kurzemnieks [ 2015 Nov 05 ]

Implemented in pre-3.0.0alpha4 (trunk) r56556

Comment by richlv [ 2015 Nov 26 ]

(19) string changes in the spec seem to be missing the latest changes, would be nice to update

iivs RESOLVED

<richlv> thank you, CLOSED

Generated at Thu Apr 25 11:15:08 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.