Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] PPLSavedQueryClient / PPLSavedVisualizationClient have incongruent get/update API #1134

Open
pjfitzgibbons opened this issue Oct 16, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@pjfitzgibbons
Copy link
Contributor

What is the bug?
A clear and concise description of the bug.

Get API returns the "raw" object as contained in .opensearch-observability index/store.
Espcially note selected_date_range, selected_timestamp, selected_fields

    const client = new PPLSavedObjectClient(coreRefs.http!);

    const res = await client.get({ objectId: metric.savedVisualizationId });
    const currentVis = res.observabilityObjectList[0].savedVisualization;

    console.log('savedMetricToObservabilityStore', { currentVis });

==>
{
    "name": "[Metric] Average ram usage per day by windows os ",
    "description": "",
    "query": "source = opensearch_dashboards_sample_data_logs | where match(machine.os,'win')  |  stats avg(machine.ram) by span(timestamp,1d)",
    "type": "line",
    "selected_date_range": {
        "start": "now/y",
        "end": "now",
        "text": ""
    },
    "selected_timestamp": {
        "name": "timestamp",
        "type": "timestamp"
    },
    "selected_fields": {
        "text": "",
        "tokens": []
    },
    "user_configs": "{\"dataConfig\":{\"series\":[{\"label\":\"machine.ram\",\"name\":\"machine.ram\",\"aggregation\":\"avg\",\"customLabel\":\"\"}],\"dimensions\":[],\"span\":{\"time_field\":[{\"name\":\"timestamp\",\"type\":\"timestamp\",\"label\":\"timestamp\"}],\"unit\":[{\"text\":\"Day\",\"value\":\"d\",\"label\":\"Day\"}],\"interval\":\"1\"}}}",
    "sub_type": "metric"
}

.update() though requires a different object model, as indicated in the definition :

  async update(
    params: UpdateParams
  ): Promise<OSDSavedObjectUpdateResponse<VisualizationSavedObjectAttributes>> {
    const body = this.buildRequestBody({
      query: params.query,
      fields: params.fields,
      dateRange: params.dateRange,
      chartType: params.type,
      name: params.name,
      timestamp: params.timestamp,
      applicationId: params.applicationId,
      userConfigs: params.userConfigs,
      description: params.description,
      subType: params.subType,
      unitsOfMeasure: params.unitsOfMeasure,
      selectedLabels: params.selectedLabels,
    });

Especially note, the params object is expected differently :

  • timestamp instead of selected_timestamp
  • fields instead of selected_fields
  • dateRange instead of selected_date_range

What is the expected behavior?
The following code should work without error :

    const client = new PPLSavedObjectClient(coreRefs.http!);

    const res = await client.get({ objectId: metric.savedVisualizationId });
    const currentVis = res.observabilityObjectList[0].savedVisualization;

    client.update(currentVis)

What is your host/environment?

  • OS: [e.g. iOS]
  • Version [e.g. 22]
  • Plugins

Do you have any screenshots?
If applicable, add screenshots to help explain your problem.

Do you have any additional context?
Add any other context about the problem.

@pjfitzgibbons pjfitzgibbons added bug Something isn't working untriaged labels Oct 16, 2023
@pjfitzgibbons
Copy link
Contributor Author

@noCharger
Copy link

@mengweieric are we still tracking 2.12 on this?

@ps48 ps48 removed the v2.12.0 label Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants