Hi! Here is another one question. Why can't I find...
# gooddata-cn
в
Hi! Here is another one question. Why can't I find a metric by name in the measures list if I get a message "Entity of ID 'new_hire_turnover' and Scope 'WorkspaceObjectScope(organization=default, space=daceb3e88abd4bd5a7af036e9876a837)' is already stored in database." What should I do to see all the metrics added via API?
j
Hello Vasilij! The first thing that caught my eye is that in the first screenshot on line 5 of the POST paylod it says "attributes" and what follows is not an array but an object, with MAQL definition. So it is no surprise that this POST ends with 400 error.
Secondly, it seems that even if the definition was correct, it still wouldn't get processed because an object with id
new_hire_turnover
already exists in the db. I can only guess that the reason you are not seeing anything under
New Hire Turnover
in the Analytical Designer is that object with id
new_hire_turnover
is neither a metric nor an attribute, or it is hidden for some reason (a disconnected dataset maybe?)
I would recommend taking it step by step. Could you please look for an existing object with id
new_hire_turnover
and let us know the full JSON definition? Let's start by checking that object with id
new_hire_turnover
is a valid metric. Let's then continue to investigate why it is not showing up in AD.
в
Hi Jiri! Here is what I find with id new_hire_turnover in the workspace JSON { "content": { "format": "#,##0", "maql": "SELECT SUM({fact/fact.dshb_hire_n_term.termamount})/ SUM({fact/fact.dshb_hire_n_term.hireamount})" }, "description": "", "id": "new_hire_turnover", "title": "New Hire Turnover" } { "content": { "buckets": [{ "items": [{ "measure": { "localIdentifier": "b081c3e2d5f445a4910711c7fea47947", "definition": { "measureDefinition": { "item": { "identifier": { "id": "fact.v_recruitment.new_hire_turnover", "type": "fact" } }, "aggregation": "avg", "filters": [] } }, "title": "Avg new_hire_turnover", "format": "#,##0.00%" } } ], "localIdentifier": "measures" } ], "filters": [], "ref": {}, "properties": {}, "sorts": [], "visualizationUrl": "local:headline", "isLocked": false, "version": "2" }
{ "content": { "buckets": [{ "items": [{ "measure": { "localIdentifier": "8fc43eca377040208a1eca59cb165f2e", "definition": { "measureDefinition": { "item": { "identifier": { "id": "new_hire_turnover", "type": "metric" } }, "filters": [] } }, "title": "New Hire Turnover", "format": "#,##0.00%" } } ], "localIdentifier": "measures" } ], "filters": [], "ref": { "uri": "http://localhost:3000/api/entities/workspaces/daceb3e88abd4bd5a7af036e9876a837/visualizationObjects/6bb30aac-4b0c-4645-9d1e-f066e48d91be" }, "identifier": "6bb30aac-4b0c-4645-9d1e-f066e48d91be", "properties": {}, "sorts": [], "uri": "http://localhost:3000/api/entities/workspaces/daceb3e88abd4bd5a7af036e9876a837/visualizationObjects/6bb30aac-4b0c-4645-9d1e-f066e48d91be", "visualizationUrl": "local:headline", "isLocked": false, "version": "2" }
j
The UI hides objects with no-longer-valid references, the metric "id:new_hire_turnover" references the
{fact/fact.dshb_hire_n_term.termamount}
only, therefore I guess this fact does not exist any more and then the UI hides the object(s).
в
Yes, This fact does not exist. What is the best way in this case to export layout and to import it to an empty workspace without getting consistency errors?
j
The right way is fix the model, that is update the metric to reference valid fact or remove such objects (recursively). The fastest way, replace occurrences of discontinued-objects by existing-ones (of the same type). The best way - is somewhere between the right and fast way, ... accordingly to semantics of affected objects.
в
@Jiri Zajic You wrote: "The first thing that caught my eye is that in the first screenshot on line 5 of the POST paylod it says "attributes" and what follows is not an array but an object, with MAQL definition. So it is no surprise that this POST ends with 400 error." but in this topic I see exhamples with
"attributes": {}
https://community.gooddata.com/metrics-and-maql-kb-articles-43/gooddata-cn-metrics-management-101-307?postid=849#post849
j
The structure you sent is all right, otherwise you would get input structure validation error. The response you received is also right, the object with the specified id already exist in the database and was hidden in the UI for referencing no longer valid fact. If you will list metrics using API on your own, you will find the metric there https://www.gooddata.com/developers/cloud-native/doc/1.3/api/api_reference_all/#/entities/getEntity%40Metrics
в
Can I use DELETE request to metrics, facts and labels endpoints to delete objects with no-longer-valid references before exporting analyticsModel.json or is it more correct to remove them from analyticsModel.json?
j
you can use DELETE request to metrics, you can't use it to logical-model (dataset, facts, labels, attributes), these are managed via declarative API only ... still, if you remove metrics, you have to clean or modify dependant objects recursively (dashboards, visualisations, execution-filters), consider thoroughly to fix the metric using existing fact 😉
j
Sorry for confusion about object structure @Василий Островский, and thanks @Jiri Schmid for clarification!