Ad Widget

Collapse

The dreaded "Cannot create item: item with the same key already exists"

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • driscoll
    Junior Member
    • Sep 2024
    • 10

    #1

    The dreaded "Cannot create item: item with the same key already exists"

    On a template, I created a Master Item which pulls a JSON via HTTP with the correct format ("data" array and so on), then I have a LLD rule as a dependent item with 2 LLD macros that extract {#PARSER_SITE} and {#PARSER_TYPE} (see below) then I have an Item Prototype that uses "parser[{#PARSER_TYPE},{#PARSER_SITE}]" as the item key. For some unknown reason, Zabbix complains that the items key already exists. But why?? I just have a single host and I already tried to unlink & clear the template on which I have the LLD.

    As you can see from the JSON, there are no two identical set of keys when using "site" and "type" (MACRO #PARSER_TYPE #PARSER_SITE)

    Here is the JSON the Master Item is getting:
    Code:
    {
    
        "data" : [
                {
                    "site": "aaa.com",
                    "delta": 223,
                    "type": "sentinel1"
                },
                {
                    "site": "bbb.com",
                    "delta": 34,
                    "type": "sentinel1"
                },
                {
                    "site": "ccc.com",
                    "delta": 22,
                    "type": "sentinel1"
                },
                {
                    "site": "ddd.com",
                    "delta": 55,
                    "type": "sentinel1"
                },
                {
                    "site": "aaa.com",
                    "delta": 66,
                    "type": "sentinel2"
                },
                {
                    "site": "bbb.com",
                    "delta": 6,
                    "type": "sentinel2"
                },
                {
                    "site": "ccc.com",
                    "delta": 0,
                    "type": "sentinel2"
                },
                {
                    "site": "ddd.com",
                    "delta": 33,
                    "type": "sentinel2"
                }
            ]
    }
    LLD MACROS:

    Click image for larger version  Name:	Screenshot 2024-09-24 at 16.45.50.png Views:	0 Size:	15.6 KB ID:	491692

    ITEM PROTOTYPE

    Click image for larger version  Name:	Screenshot 2024-09-24 at 17.11.25.png Views:	0 Size:	27.2 KB ID:	491693

    ERROR
    Click image for larger version  Name:	Screenshot 2024-09-24 at 17.14.10.png Views:	0 Size:	70.6 KB ID:	491694

    Any idea?
    Last edited by driscoll; 24-09-2024, 17:22.
  • driscoll
    Junior Member
    • Sep 2024
    • 10

    #2
    OMG it's so difficult to get help with this product

    Comment

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

      #3
      It is a voluntary forum. Not everyone reads it every day. Not everyone has an answer to your question. Not everyone has time to try to play through your use case... Don't take it as personal insult, that noone answered your case...
      Want quick answers, buy support...

      Comment

      • ISiroshtan
        Senior Member
        • Nov 2019
        • 324

        #4
        Absolutely back up what Cyber says. If you want a reliable support you have multitude of options:
        1. Pay Zabbix for support
        2. Get Zabbix trainings
        3. Spend some time double-triple checking available Zabbix documentation, answer is usually in there
        4. Hire engineers proficient in Zabbix
        Options are there

        As to your problem:
        If it says "Cannot create item: item with the same key already exists" it should have created at least one item. Check info about that item. What kind of key it assigned and how it populated your LLD macros. I have a strong suspicion that your LLD macros would end up empty.
        If you would reference documentation regarding LLD macro you would see following:
        JSONPath Path that is used to extract LLD macro value from a LLD row, using JSONPath syntax.
        The values extracted from the returned JSON are used to replace the LLD macros in item, trigger, etc. prototype fields.
        JSONPath can be specified using the dot notation or the bracket notation. Bracket notation should be used in case of any special characters and Unicode, like $['unicode + special chars #1']['unicode + special chars #2'].

        For example, $.foo will extract "bar" and "baz" from this JSON: [{"foo":"bar"}, {"foo":"baz"}]
        Note that $.foo will extract "bar" and "baz" also from this JSON: {"data":[{"foo":"bar"}, {"foo":"baz"}]} because a single "data" object is processed automatically (for backwards compatibility with the low-level discovery implementation in Zabbix versions before 4.2).
        In essence, your JSONPath points to desired data from top of JSON you pass into discovery. But what Zabbix does is iterates through all element in "data" array in your JSON and for each object iterated applies JSONPath you provided. So iterated objects will not have "data" node resulting in empty result of JSONPath application. In your case it should be $.site for {#PARSER_SITE} and $.type for {#PARSER_TYPE}

        Comment

        • rich@974
          Junior Member
          • Oct 2024
          • 13

          #5
          I work for a local goverment office and I really really wish I can hire some zabbix specialists to handle the monitoring project I'm in charge of...
          but until I alone can settup a proper working proof of concept, we will be stuck with that god damn centreon garbage.

          So I understand all to well that zabbix cannot offer all the support for free, but should I just give up because all my efforts was not enough to
          get us started with zabbix ?

          if anyone can make sense of this

          the zabbix cause will advance here

          thx for reading

          Comment

          • troffasky
            Senior Member
            • Jul 2008
            • 565

            #6
            Originally posted by rich@974
            I work for a local goverment office and I really really wish I can hire some zabbix specialists to handle the monitoring project I'm in charge of...
            but until I alone can settup a proper working proof of concept, we will be stuck with that god damn centreon garbage.
            The logic of this eludes me, if you get it working alone, you wouldn't need to hire a specialist!
            The two posts before yours are still true, regardless of any special pleading.

            Comment

            • rich@974
              Junior Member
              • Oct 2024
              • 13

              #7
              Originally posted by troffasky
              The logic of this eludes me, if you get it working alone, you wouldn't need to hire a specialist!
              The two posts before yours are still true, regardless of any special pleading.
              I'm glad you ask
              You see the thing is I'm a Project manager in the public sector.
              As a project manager my job is not to be a Infrastructure Monitoring/Supervising operator
              My job is to find the best solution, both in term of technical efficiency and spending of public money, for, today, Infrastructure Monitoring/Supervising.
              So my task list is:
              - Get to know what the sector looks like
              - Study precisly the needs and capabilities we have
              - Weight the differents solutions and strategies we could use
              - And finaly establish a contract that meets our requierments AND offer a fair chance to anyone willing to compet for it.

              So for the 3 first points, I do a lot of research, read a lot of documentation and exchange a lot with both our technicians and
              people in companies willing to participate in what we call "sourcing"
              The thing is that is not enought. And the current state of our monitoring, rolling like it as been for the last 15 years, is here to prove it.
              On the one side our team is to buzy running the whole thing with limited resources to spend much time fiddling around with monitoring solutions
              and on the other side the companies we interview have an obligation to sell their solution, in a manner that prevents us to see clearly what is what.
              So we resort to Proof Of Concept, which means we have to evlauate ourself what the solutions do, how they do it, and how they perform both
              in terms of results and in terms of their costs. We need to go past the commercial, "before sale", stage of a solution to be good public servant, don't you think?

              One good thing I learn for my few years in the public sector is that, "you cannot do a good job of externalising a job that you can't do".
              So my wish here, specially with an open source solution like Zabbix, is to setup a proper Monitoring system for our System, and use it to start a
              collaboration (a contract) with people from the private sector who will maintain it, optimise it, and keep its evolution on the right track.

              Does that make sense ? What about that logic ?

              Comment

              Working...