API Connect

API Connect

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  Analytics not showing target URL

    Posted Wed July 05, 2023 12:24 PM

    Hi All,

    We want to see the target-URL in the APIC connect Analytics logs, currently we are using DPOD to check the target-URL but if we can see them in Analytics server it will save our time.


    I have gone though IBM documentations to create a custom flag here is the example of that, but do we have any simpler solution to check the target_URL, without tweaking the code.

    Custom Code: 
     - log:
              version: 2.1.0
              title: log
              log-level: default
              mode: gather-only
          - gatewayscript:
              version: 2.0.0
              title: gatewayscript
              source: "var logs = context.get('log');\r\n  if (logs) {\r\n    if (!logs.target_url) {  \r\n      logs.target_url = {};\r\n    }\r\n    logs.target_url = '$(targeturl)';\r\n   \r\n    context.set('log', logs);\r\n  }"
     

    Also can how can we read target-url from invoke assembly? Is it possible to read invoke assembly attributes, I'm majorly concerned about target-url?



    ------------------------------
    sourabh singhal
    ------------------------------


  • 2.  RE: Analytics not showing target URL

    Posted Thu July 06, 2023 03:30 AM

    Hiya,

    The docs here should explain how to add additional data to the analytics log record: https://www.ibm.com/docs/en/api-connect/10.0.5.x_lts?topic=analytics-modifying-api-event-data

    Note that you will want to add the extra data to the custom_data array, that way you will be able to query it from the analytics API and UI. If you just add it to the route of the log record as you are doing then it likely will not be stored in analytics in the first place, but it definitely will not be queryable via the API/UI. This is precisely what the custom_data array is for.

    Hope that helps!

    Chris



    ------------------------------
    Chris Dudley
    ------------------------------



  • 3.  RE: Analytics not showing target URL

    Posted Thu July 06, 2023 06:22 PM

    Hi Chris,

    Thanks for replying.

    Could you please also help me about :

    Also can how can we read target-url from invoke assembly? Is it possible to read any I build assembly parameters? 



    ------------------------------
    sourabh singhal
    ------------------------------



  • 4.  RE: Analytics not showing target URL

    Posted Fri July 07, 2023 06:36 AM

    I'm afraid I don't know about that specific one.

    The context variables are listed here: https://www.ibm.com/docs/en/api-connect/10.0.5.x_lts?topic=reference-api-connect-context-variables



    ------------------------------
    Chris Dudley
    ------------------------------



  • 5.  RE: Analytics not showing target URL

    Posted Tue July 11, 2023 05:30 PM

    Hi Sourabh,

    target-url is just a variable in context, and specifically it is most probably an api property.  In GatewayScript you could use context.get('target-url') for example.  The invoke is using the value of target-url at that point in time.  If indeed in an api property that shouldn't change, but you could create your own context variables which could change values at any time and then reference them in your invoke target-url, so it that is the case, you would need to save that variable into another variable before you change the value.

    Best Regards,
    Steve



    ------------------------------
    Steve Linn
    Senior Consulting I/T Specialist
    IBM
    ------------------------------



  • 6.  RE: Analytics not showing target URL

    Posted Fri September 01, 2023 11:51 AM

    @sourabh Singhal : Are you able to solve this issue?



    ------------------------------
    Manojkumar Phate
    ------------------------------



  • 7.  RE: Analytics not showing target URL

    Posted Tue December 12, 2023 01:35 PM

    Hello sourabh

    I had a same issue for adding backside url and I have solved it.

    Gatewayscript like below. I used datapower service variable var://service/URL-out, which contains backside url and in analytics I can see backside_url endpoint

    - gatewayscript:
    version: 2.0.0
    title: modify log content
    source: >-
    const sm = require('service-metadata');
    const logs = context.get('log');
    if (logs) {
    if (!logs.backside) {
    logs.backside = {};
    }
    logs.backside_url = sm.getVar('var://service/URL-out');
    context.set('log', logs);
    }


    ------------------------------
    Juha Mikkonen
    ------------------------------



  • 8.  RE: Analytics not showing target URL

    Posted Tue December 12, 2023 01:52 PM

    Nice work solving it.

    Please add extra data for analytics to the custom_data element rather than the root of the log object. Otherwise you won't be able to query and search for the data via the api or ui.



    ------------------------------
    Chris Dudley
    ------------------------------