# Get the Number of Fields on an Index

To get the number of fields in an index created by Logstash in Elasticsearch, you can use Elasticsearch's RESTful API to retrieve the index mapping. The mapping contains information about the fields in the index, including their types. Here's how you can do it:

### Step 1: Query the Index Mapping

You can use the `_mapping` API to retrieve the mapping for a specific index. Replace `your_index_name` with the name of your Logstash-created index.

```bash
GET /your_index_name/_mapping
```

You can execute this command using tools like **Kibana Dev Tools**, **cURL**, or any REST client.

### Example using cURL

To execute this using cURL, you can run the following command in your terminal:

```bash
curl -X GET "<http://localhost:9200/your_index_name/_mapping?pretty>"
```

### Step 2: Count the Fields

The response will include the mapping for the index, which looks something like this:

```json
{
  "your_index_name": {
    "mappings": {
      "properties": {
        "field1": {
          "type": "text"
        },
        "field2": {
          "type": "keyword"
        },
        // ... more fields ...
      }
    }
  }
}

```

To count the number of fields, you can either:

1. **Manually Count**: Look through the `properties` section and count the fields.
2. **Use a Script or Tool**: If you want to automate this, you can parse the JSON response and count the fields programmatically.

### Example Script to Count Fields

Here's a simple example in Python using the `requests` library to count the fields:

```python
import requests

# Replace with your Elasticsearch URL
url = "<http://localhost:9200/your_index_name/_mapping>"
response = requests.get(url)
mapping = response.json()

# Count the number of fields
field_count = len(mapping['your_index_name']['mappings']['properties'])
print(f"Number of fields in the index: {field_count}")
```

### Step 3: Summary

1. Use the `_mapping` API to get the mapping of your index.
2. Count the number of fields present in the `properties` section of the mapping.
3. Optionally, use a script to automate the counting process.

By following these steps, you can easily determine the number of fields present in your Logstash-created index in Elasticsearch.