Ad Widget

Collapse

Unable to Attach a Template to a Host Key itemtagid already exists.

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • oneCrazyAdmin
    Junior Member
    • Nov 2022
    • 8

    #1

    Unable to Attach a Template to a Host Key itemtagid already exists.

    Good Afternoon,

    I recently upgraded Zabbix to 7.2.2. I am running it inside Docker containers. When I try to add a host, I am able to add the host, but only if I don't assign a template to the host. If i assign a template to the host, I get this error

    Click image for larger version

Name:	2025-01-27_16-20.png
Views:	120
Size:	45.7 KB
ID:	497983

    Detail: Key itemtagid already exits. It doesn't matter what template I attach, I am getting these errors.

    Help!
  • Answer selected by oneCrazyAdmin at 30-01-2025, 01:00.
    cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    I have seen following case...
    There is a table called "ids". It contains "last id that was used" for many tables, including item_tag... It may be out of sync in some reason, DB crash or whatever...

    Your error says, that for the item with id 912073 it is unable to insert a tag "component" with value "health", when using itemtagid 948829

    you can compare those... should be same, at least if you dont step into some moment when new stuff is created just between queries..

    select * from item_tag order by itemtagid DESC limit 1;
    select nextid from ids where table_name = 'item_tag';

    I dont know why they call it "nextid", when it is actually "last that was used"... but nevermind.. If value from ids is smaller, then it probably needs to be updated to same value as other.

    Comment

    • Blevar
      Member
      • Jan 2025
      • 68

      #2
      This looks like you had some issues with updating.
      You have to look into your database for duplicated items and remove them. (Backup your data first)

      Comment

      • oneCrazyAdmin
        Junior Member
        • Nov 2022
        • 8

        #3
        Is it just in that table? Is there any cleanup scripts that I might be able to look at?

        How is that item tag generated?

        Comment

        • cyber
          Senior Member
          Zabbix Certified SpecialistZabbix Certified Professional
          • Dec 2006
          • 4807

          #4
          I have seen following case...
          There is a table called "ids". It contains "last id that was used" for many tables, including item_tag... It may be out of sync in some reason, DB crash or whatever...

          Your error says, that for the item with id 912073 it is unable to insert a tag "component" with value "health", when using itemtagid 948829

          you can compare those... should be same, at least if you dont step into some moment when new stuff is created just between queries..

          select * from item_tag order by itemtagid DESC limit 1;
          select nextid from ids where table_name = 'item_tag';

          I dont know why they call it "nextid", when it is actually "last that was used"... but nevermind.. If value from ids is smaller, then it probably needs to be updated to same value as other.

          Comment

          • oneCrazyAdmin
            Junior Member
            • Nov 2022
            • 8

            #5
            Thank you so much! the nextid was set to a number that was less than what was in the item_tag table. updating that to a number that was higher allowed me to attach templates again.

            Comment

            Working...