opensearch-project / opensearch-metrics

OpenSearch Metrics
https://metrics.opensearch.org
Apache License 2.0
1 stars 4 forks source link

[BUG] Mapping issue with OpenSearch Gradle Check Metrics #39

Closed prudhvigodithi closed 1 month ago

prudhvigodithi commented 1 month ago

What is the bug?

Today for OpenSearch Gradle Check Metrics, the publishGradleCheckTestResults.groovy is used to collect the gradle test failures from jenkins job and index to the metrics cluster. The index creation is done as gradle-check-\$MONTH_YEAR and wont create if the index already exists.

With the new fields added (https://github.com/opensearch-project/OpenSearch/pull/13786 and https://github.com/opensearch-project/opensearch-build/pull/4719) in the gradle check workflow when indexing these fields to an already existing index and its own mapping, OpenSearch created the default index mapping. Now with this PR https://github.com/opensearch-project/opensearch-build-libraries/pull/427 the field mappings that are added for the new fields which will take effect for the new index's broke the existing visualizations.

What is the expected behavior?

The visualizations in OpenSearch Gradle Check Metrics dashboard should load the latest data from index pattern created that match gradle-check-\$MONTH_YEAR.

prudhvigodithi commented 1 month ago

[Triage] To fix the visualizations using the gradle-check-06-2024:

Create the temporary index gradle-check-06-2024-new with the desired working mapping that is working for previous month index gradle-check-05-2024.

PUT /gradle-check-06-2024-new
{
  "mappings": {
    "properties": {
      "build_duration": {
        "type": "float"
      },
      "build_number": {
        "type": "integer"
      },
      "build_result": {
        "type": "keyword"
      },
      "build_start_time": {
        "type": "date"
      },
      "git_reference": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "invoke_type": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "pr_description": {
        "type": "text"
      },
      "pull_request": {
        "type": "keyword"
      },
      "pull_request_owner": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "pull_request_title": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "test_class": {
        "type": "keyword"
      },
      "test_fail_count": {
        "type": "integer"
      },
      "test_name": {
        "type": "keyword"
      },
      "test_passed_count": {
        "type": "integer"
      },
      "test_skipped_count": {
        "type": "integer"
      },
      "test_status": {
        "type": "keyword"
      }
    }
  }
}

Copy the data to created temporary index.

POST /_reindex
{
  "source": {
    "index": "gradle-check-06-2024"
  },
  "dest": {
    "index": "gradle-check-06-2024-new"
  }
}

Delete the index once the data is copied and verified to temporary index.

DELETE /gradle-check-06-2024

Create the index gradle-check-06-2024 with the desired working mapping.

PUT /gradle-check-06-2024
{
  "mappings": {
    "properties": {
      "build_duration": {
        "type": "float"
      },
      "build_number": {
        "type": "integer"
      },
      "build_result": {
        "type": "keyword"
      },
      "build_start_time": {
        "type": "date"
      },
      "git_reference": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "invoke_type": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "pr_description": {
        "type": "text"
      },
      "pull_request": {
        "type": "keyword"
      },
      "pull_request_owner": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "pull_request_title": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "test_class": {
        "type": "keyword"
      },
      "test_fail_count": {
        "type": "integer"
      },
      "test_name": {
        "type": "keyword"
      },
      "test_passed_count": {
        "type": "integer"
      },
      "test_skipped_count": {
        "type": "integer"
      },
      "test_status": {
        "type": "keyword"
      }
    }
  }
}

Copy the data from temporary index to gradle-check-06-2024.

POST /_reindex
{
  "source": {
    "index": "gradle-check-06-2024-new"
  },
  "dest": {
    "index": "gradle-check-06-2024"
  }
}

Delete the temporary index after copying the data and once verified

DELETE /gradle-check-06-2024-new

Adding @getsaurabh02 @bshien @rishabh6788

prudhvigodithi commented 1 month ago

The related change is already merged https://github.com/opensearch-project/opensearch-build-libraries/pull/434, we can close this once a new library version is released with the above PR change and once the Jenkins file is updated with the new released library. @getsaurabh02 @rishabh6788

prudhvigodithi commented 1 month ago

This issue is now resolved as the change has been included in the library release starting from version 6.5.0. Thank you @getsaurabh02