As we are rolling out the user profile feature, we'd like to expand the [Usage API](https://www.elastic.co/guide/en/elasticsearch/reference/current/usage-api.html) to report usage stats of user profiles such as (1) number of enabled user profiles and (2) number of user profiles that are [activated](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-activate-user-profile.html) over the past X days. 

Response of the Usage API already contains a `security` field that groups relevant stats from security related features. We expect the new stats for user profiles should be added under it as well, for example:
```
{
  "security: {
    "user_profile": {
      "activated": 78,
      "recently_activated": 42  <1>
    }
  }
}
```
<1> The use of `recently_` is chosen to avoid the field to be tied to a specific time period so it is easier to evolve the definition in future.

x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/profile/ProfileService.java
import org.elasticsearch.xpack.core.security.authc.Subject;
import org.elasticsearch.xpack.core.security.user.User;
import org.elasticsearch.xpack.security.support.SecurityIndexManager;
import java.io.IOException;
import java.time.Clock;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.TreeMap;
import java.util.function.Function;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import static org.elasticsearch.action.bulk.TransportSingleItemBulkWriteAction.toSingleItemBulkRequest;
import static org.elasticsearch.common.Strings.collectionToCommaDelimitedString;
import static org.elasticsearch.core.Strings.format;
import static org.elasticsearch.xpack.core.ClientHelper.SECURITY_ORIGIN;
import static org.elasticsearch.xpack.core.ClientHelper.SECURITY_PROFILE_ORIGIN;
import static org.elasticsearch.xpack.core.ClientHelper.executeAsyncWithOrigin;
import static org.elasticsearch.xpack.core.security.authc.Authentication.isFileOrNativeRealm;
import static org.elasticsearch.xpack.security.support.SecuritySystemIndices.SECURITY_PROFILE_ALIAS;
import static org.elasticsearch.xpack.security.support.SecuritySystemIndices.VERSION_SECURITY_PROFILE_ORIGIN;
public class ProfileService {